home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / host contacted / jikes.lha / jikes-1.11 / src / java.g < prev    next >
Text File  |  1999-10-20  |  123KB  |  4,994 lines

  1. %options scopes,act,an=javaact.cpp,hn=javaact.h,em,tab,gp=c++,
  2. %options fp=java,escape=$,prefix=TK_,em,defer,output-size=125
  3. %options hblockb=\:,hblocke=:\
  4. %options nogoto-default
  5. %options single-productions
  6. %options la=2,names=max
  7. -- $Id: java.g,v 1.14 1999/10/19 23:13:37 shields Exp $
  8. -- This software is subject to the terms of the IBM Jikes Compiler
  9. -- License Agreement available at the following URL:
  10. -- http://www.ibm.com/research/jikes.
  11. -- Copyright (C) 1996, 1999, International Business Machines Corporation
  12. -- and others.  All Rights Reserved.
  13. -- You must accept the terms of that agreement to use this software.
  14.  
  15. ------------------------------------------------------------------------
  16. --
  17. --                               J A V A
  18. --
  19. -- This Java grammar is almost identical to the grammar defined in
  20. -- chapter 19 of the Java Language Specification manual together with
  21. -- the additional rules found in the 1.1 document. It is written here
  22. -- in JIKES PG format with semantic actions following each rule. In
  23. -- specifying the rules we enclosed all terminal symbols in single
  24. -- quotes so that they can be quickly distinguished from
  25. -- non-terminals. Optional symbols are suffixed with a question mark (?)
  26. -- and the rules expanding such definitions can be found at the end.
  27. --
  28. -- This grammar is totally faithful to the original rules except that
  29. -- some syntactic markers: PackageHeaderMarker, MethodHeaderMarker and
  30. -- BodyMarker, were added to allow the parser to skip certain irrelevant
  31. -- syntactic components when they are not needed.
  32. --
  33. -- The file javaact.h produced by JIKESPG from this file (java.g) contains a
  34. -- very readable definition of the grammar rules together with their
  35. -- associated semantic actions. That file is marked with appropriate
  36. -- location directives (automatically generated) which instructs the C++
  37. -- compiler to issue error messages in terms of this file (java.g).
  38. -- Therefore, though the user is encouraged to read javaact.h, no
  39. -- change should ever be made to that file. Instead, changes should
  40. -- always be made in this file and javaact.h should be regenerated
  41. -- using JIKESPG.
  42. --
  43. ------------------------------------------------------------------------
  44.  
  45. $Define
  46.  
  47. --
  48. -- This macro generates a header for an action function consisting
  49. -- of the rule in question (commented) and a location directive.
  50. --
  51. $location
  52. /.
  53.  
  54. //
  55. // Rule $rule_number:  $rule_text
  56. //
  57. #line $next_line "$input_file"./
  58.  
  59. --
  60. -- This macro is used to initialize the rule_action array
  61. -- to an unnamed function. A name is generated using the
  62. -- number of the rule in question.
  63. --
  64. $action
  65. /.
  66. #ifndef HEADERS
  67.     rule_action[$rule_number] = &Parser::Act$rule_number;
  68. #else
  69.     void Act$rule_number(void);
  70. #endif
  71. ./
  72.  
  73. --
  74. -- These macros are used to initialize the rule_action array
  75. -- to a specific named function.
  76. --
  77. $MakeArrayType
  78. /.
  79. #ifndef HEADERS
  80.     rule_action[$rule_number] = &Parser::MakeArrayType;
  81. #endif
  82. ./
  83.  
  84. $MakeSimpleName
  85. /.
  86. #ifndef HEADERS
  87.     rule_action[$rule_number] = &Parser::MakeSimpleName;
  88. #endif
  89. ./
  90.  
  91. $MakeFieldAccess
  92. /.
  93. #ifndef HEADERS
  94.     rule_action[$rule_number] = &Parser::MakeFieldAccess;
  95. #endif
  96. ./
  97.  
  98. $MakeQualifiedSuper
  99. /.
  100. #ifndef HEADERS
  101.     rule_action[$rule_number] = &Parser::MakeQualifiedSuper;
  102. #endif
  103. ./
  104.  
  105. $MakeQualifiedNew
  106. /.
  107. #ifndef HEADERS
  108.     rule_action[$rule_number] = &Parser::MakeQualifiedNew;
  109. #endif
  110. ./
  111.  
  112. $SetSym1ToSym2
  113. /.
  114. #ifndef HEADERS
  115.     rule_action[$rule_number] = &Parser::SetSym1ToSym2;
  116. #endif
  117. ./
  118.  
  119. $MakeEmptyStatement
  120. /.
  121. #ifndef HEADERS
  122.     rule_action[$rule_number] = &Parser::MakeEmptyStatement;
  123. #endif
  124. ./
  125.  
  126. $MakeLabeledStatement
  127. /.
  128. #ifndef HEADERS
  129.     rule_action[$rule_number] = &Parser::MakeLabeledStatement;
  130. #endif
  131. ./
  132.  
  133. $MakeExpressionStatement
  134. /.
  135. #ifndef HEADERS
  136.     rule_action[$rule_number] = &Parser::MakeExpressionStatement;
  137. #endif
  138. ./
  139.  
  140. $MakeIfThenElseStatement
  141. /.
  142. #ifndef HEADERS
  143.     rule_action[$rule_number] = &Parser::MakeIfThenElseStatement;
  144. #endif
  145. ./
  146.  
  147. $MakeWhileStatement
  148. /.
  149. #ifndef HEADERS
  150.     rule_action[$rule_number] = &Parser::MakeWhileStatement;
  151. #endif
  152. ./
  153.  
  154. $MakeForStatement
  155. /.
  156. #ifndef HEADERS
  157.     rule_action[$rule_number] = &Parser::MakeForStatement;
  158. #endif
  159. ./
  160.  
  161. $MakeArrayCreationExpression
  162. /.
  163. #ifndef HEADERS
  164.     rule_action[$rule_number] = &Parser::MakeArrayCreationExpression;
  165. #endif
  166. ./
  167.  
  168. $MakeSuperFieldAccess
  169. /.
  170. #ifndef HEADERS
  171.     rule_action[$rule_number] = &Parser::MakeSuperFieldAccess;
  172. #endif
  173. ./
  174.  
  175. $MakeSuperDoubleFieldAccess
  176. /.
  177. #ifndef HEADERS
  178.     rule_action[$rule_number] = &Parser::MakeSuperDoubleFieldAccess;
  179. #endif
  180. ./
  181.  
  182. $MakeArrayAccess
  183. /.
  184. #ifndef HEADERS
  185.     rule_action[$rule_number] = &Parser::MakeArrayAccess;
  186. #endif
  187. ./
  188.  
  189. $MakeCastExpression
  190. /.
  191. #ifndef HEADERS
  192.     rule_action[$rule_number] = &Parser::MakeCastExpression;
  193. #endif
  194. ./
  195.  
  196. --
  197. -- This macro is used to initialize the rule_action array
  198. -- to the NullAction function.
  199. --
  200. $NullAction
  201. /.
  202. #ifndef HEADERS
  203.     rule_action[$rule_number] = &Parser::NullAction;
  204. #endif
  205. ./
  206.  
  207. --
  208. -- This macro is used to initialize the rule_action array
  209. -- to the NoAction function.
  210. --
  211. $NoAction
  212. /.
  213. #ifndef HEADERS
  214.     rule_action[$rule_number] = &Parser::NoAction;
  215. #endif
  216. ./
  217.  
  218. --
  219. -- This macro generates a header for a named action function that is
  220. -- already defined and will be shared.
  221. --
  222. $shared_function
  223. /.
  224.  
  225. //
  226. // Rule $rule_number:  $rule_text./
  227.  
  228. --
  229. -- This macro generates a header for a rule that invokes the
  230. -- no_function routine.
  231. --
  232. $shared_NoAction
  233. /.
  234.  
  235. //
  236. // Rule $rule_number:  $rule_text
  237. //
  238. // void NoAction(void);
  239. //./
  240.  
  241. --
  242. -- This macro generates a header for a rule that invokes the
  243. -- null_function routine.
  244. --
  245. $shared_NullAction
  246. /.
  247.  
  248. //
  249. // Rule $rule_number:  $rule_text
  250. //
  251. // void NullAction(void);
  252. //./
  253.  
  254. $Terminals
  255.  
  256.     BodyMarker
  257.  
  258.     Identifier
  259.  
  260.     abstract boolean break byte case catch char class const
  261.     continue default do double else extends false final finally float
  262.     for goto if implements import instanceof int
  263.     interface long native new null package private
  264.     protected public return short static strictfp super switch
  265.     synchronized this throw throws transient true try void
  266.     volatile while
  267.  
  268.     IntegerLiteral
  269.     LongLiteral
  270.     FloatingPointLiteral
  271.     DoubleLiteral
  272.     CharacterLiteral
  273.     StringLiteral
  274.  
  275.     PLUS_PLUS
  276.     MINUS_MINUS
  277.     EQUAL_EQUAL
  278.     LESS_EQUAL
  279.     GREATER_EQUAL
  280.     NOT_EQUAL
  281.     LEFT_SHIFT
  282.     RIGHT_SHIFT
  283.     UNSIGNED_RIGHT_SHIFT
  284.     PLUS_EQUAL
  285.     MINUS_EQUAL
  286.     MULTIPLY_EQUAL
  287.     DIVIDE_EQUAL
  288.     AND_EQUAL
  289.     OR_EQUAL
  290.     XOR_EQUAL
  291.     REMAINDER_EQUAL
  292.     LEFT_SHIFT_EQUAL
  293.     RIGHT_SHIFT_EQUAL
  294.     UNSIGNED_RIGHT_SHIFT_EQUAL
  295.     OR_OR
  296.     AND_AND
  297.     PLUS
  298.     MINUS
  299.     NOT
  300.     REMAINDER
  301.     XOR
  302.     AND
  303.     MULTIPLY
  304.     OR
  305.     TWIDDLE
  306.     DIVIDE
  307.     GREATER
  308.     LESS
  309.     LPAREN
  310.     RPAREN
  311.     LBRACE
  312.     RBRACE
  313.     LBRACKET
  314.     RBRACKET
  315.     SEMICOLON
  316.     QUESTION
  317.     COLON
  318.     COMMA
  319.     DOT
  320.     EQUAL
  321.  
  322.     ERROR
  323.     EOF
  324.     EOL
  325.  
  326. $Alias
  327.  
  328.     '++'   ::= PLUS_PLUS
  329.     '--'   ::= MINUS_MINUS
  330.     '=='   ::= EQUAL_EQUAL
  331.     '<='   ::= LESS_EQUAL
  332.     '>='   ::= GREATER_EQUAL
  333.     '!='   ::= NOT_EQUAL
  334.     '<<'   ::= LEFT_SHIFT
  335.     '>>'   ::= RIGHT_SHIFT
  336.     '>>>'  ::= UNSIGNED_RIGHT_SHIFT
  337.     '+='   ::= PLUS_EQUAL
  338.     '-='   ::= MINUS_EQUAL
  339.     '*='   ::= MULTIPLY_EQUAL
  340.     '/='   ::= DIVIDE_EQUAL
  341.     '&='   ::= AND_EQUAL
  342.     '|='   ::= OR_EQUAL
  343.     '^='   ::= XOR_EQUAL
  344.     '%='   ::= REMAINDER_EQUAL
  345.     '<<='  ::= LEFT_SHIFT_EQUAL
  346.     '>>='  ::= RIGHT_SHIFT_EQUAL
  347.     '>>>=' ::= UNSIGNED_RIGHT_SHIFT_EQUAL
  348.     '||'   ::= OR_OR
  349.     '&&'   ::= AND_AND
  350.  
  351.     '+'    ::= PLUS
  352.     '-'    ::= MINUS
  353.     '!'    ::= NOT
  354.     '%'    ::= REMAINDER
  355.     '^'    ::= XOR
  356.     '&'    ::= AND
  357.     '*'    ::= MULTIPLY
  358.     '|'    ::= OR
  359.     '~'    ::= TWIDDLE
  360.     '/'    ::= DIVIDE
  361.     '>'    ::= GREATER
  362.     '<'    ::= LESS
  363.     '('    ::= LPAREN
  364.     ')'    ::= RPAREN
  365.     '{'    ::= LBRACE
  366.     '}'    ::= RBRACE
  367.     '['    ::= LBRACKET
  368.     ']'    ::= RBRACKET
  369.     ';'    ::= SEMICOLON
  370.     '?'    ::= QUESTION
  371.     ':'    ::= COLON
  372.     ','    ::= COMMA
  373.     '.'    ::= DOT
  374.     '='    ::= EQUAL
  375.  
  376.     $EOF   ::= EOF
  377.     $ERROR ::= ERROR
  378.  
  379.     $EOL   ::= ;
  380.  
  381. $Start
  382.  
  383.     Goal
  384.  
  385. $Rules
  386.  
  387. \:
  388. //
  389. // This software is subject to the terms of the IBM Jikes Compiler Open
  390. // Source License Agreement available at the following URL:
  391. // http://www.ibm.com/research/jikes.
  392. // Copyright (C) 1996, 1998, International Business Machines Corporation
  393. // and others.  All Rights Reserved.
  394. // You must accept the terms of that agreement to use this software.
  395. //
  396.  
  397. #ifndef HEADERS
  398. void Parser::InitRuleAction()
  399. {
  400.     rule_action[0] = &Parser::BadAction;
  401. #else
  402.     void BadAction(void);
  403.     void NoAction(void);
  404.     void NullAction(void);
  405.     void MakeArrayType(void);
  406.     void MakeSimpleName(void);
  407.     void MakeFieldAccess(void);
  408.     void MakeQualifiedSuper(void);
  409.     void MakeQualifiedNew(void);
  410.     void SetSym1ToSym2(void);
  411.     void MakeEmptyStatement(void);
  412.     void MakeLabeledStatement(void);
  413.     void MakeExpressionStatement(void);
  414.     void MakeIfThenElseStatement(void);
  415.     void MakeWhileStatement(void);
  416.     void MakeForStatement(void);
  417.     void MakeArrayCreationExpression(void);
  418.     void MakeSuperFieldAccess(void);
  419.     void MakeSuperDoubleFieldAccess(void);
  420.     void MakeArrayAccess(void);
  421.     void MakeCastExpression(void);
  422. #endif
  423.  
  424. :\
  425.  
  426. /.#line $next_line "$input_file"
  427. //
  428. // This software is subject to the terms of the IBM Jikes Compiler Open
  429. // Source License Agreement available at the following URL:
  430. // http://www.ibm.com/research/jikes.
  431. // Copyright (C) 1996, 1998, International Business Machines Corporation
  432. // and others.  All Rights Reserved.
  433. // You must accept the terms of that agreement to use this software.
  434. //
  435.  
  436. #include "config.h"
  437. #include "parser.h"
  438. #include "ast.h"
  439.  
  440. #undef HEADERS
  441. #include "javaact.h"
  442.  
  443. //****************************************************************************//
  444. //****************************************************************************//
  445. //*                                                                          *//
  446. //* Below, we show each rule of the Java grammar together with the semantic  *//
  447. //* action that is invoked when the parser performs a reduction by that rule.*//
  448. //*                                                                          *//
  449. //****************************************************************************//
  450. //****************************************************************************//
  451.  
  452. ./
  453.  
  454. --18.2 Productions from 2.3: The syntactic Grammar
  455.  
  456. Goal -> CompilationUnit
  457. \:$NoAction:\
  458. /.$location
  459. //
  460. // Given a rule of the form A ::= x1 x2 ... xn        n >= 1
  461. //
  462. // Do nothing - Whatever Ast was produced for x1 is inherited by A.
  463. //
  464. void Parser::BadAction(void) { assert(false); }
  465. void Parser::NoAction(void) {}
  466. ./
  467.  
  468. Goal ::= BodyMarker ConstructorBody
  469. \:$action:\
  470. /.$location
  471. //
  472. // This rule was added to allow the parser to recognize the body of a
  473. // funtion (constructor or method, as the definition of the body of a
  474. // method is subsumed by the definition of the body of a constructor)
  475. // out of context. Note that the artificial terminal BodyMarker is
  476. // added here to prevent an ordinary parse from accepting a body as
  477. // a valid input - i.e., to recognize a body out-of-context, the
  478. // BodyMarker terminal must be inserted in front of the input stream
  479. // containing the body in question.
  480. //
  481. void Parser::Act$rule_number(void)
  482. {
  483.     Sym(1) = Sym(2);
  484. }
  485. ./
  486.  
  487.  
  488. --18.3 Productions from 3: Lexical Structure
  489. --
  490. -- Expand the definition IntegerLiteral and BooleanLiteral
  491. --
  492.  
  493. Literal ::= IntegerLiteral
  494. \:$action:\
  495. /.$location
  496. void Parser::Act$rule_number(void)
  497. {
  498.     Sym(1) = ast_pool -> NewIntegerLiteral(Token(1));
  499. }
  500. ./
  501.  
  502. Literal ::= LongLiteral
  503. \:$action:\
  504. /.$location
  505. void Parser::Act$rule_number(void)
  506. {
  507.     Sym(1) = ast_pool -> NewLongLiteral(Token(1));
  508. }
  509. ./
  510.  
  511. Literal ::= FloatingPointLiteral
  512. \:$action:\
  513. /.$location
  514. void Parser::Act$rule_number(void)
  515. {
  516.     Sym(1) = ast_pool -> NewFloatingPointLiteral(Token(1));
  517. }
  518. ./
  519.  
  520. Literal ::= DoubleLiteral
  521. \:$action:\
  522. /.$location
  523. void Parser::Act$rule_number(void)
  524. {
  525.     Sym(1) = ast_pool -> NewDoubleLiteral(Token(1));
  526. }
  527. ./
  528.  
  529. Literal -> BooleanLiteral
  530. \:$NoAction:\
  531. /.$shared_NoAction./
  532.  
  533. Literal ::= CharacterLiteral
  534. \:$action:\
  535. /.$location
  536. void Parser::Act$rule_number(void)
  537. {
  538.     Sym(1) = ast_pool -> NewCharacterLiteral(Token(1));
  539. }
  540. ./
  541.  
  542. Literal ::= StringLiteral
  543. \:$action:\
  544. /.$location
  545. void Parser::Act$rule_number(void)
  546. {
  547.     Sym(1) = ast_pool -> NewStringLiteral(Token(1));
  548. }
  549. ./
  550.  
  551. Literal ::= null
  552. \:$action:\
  553. /.$location
  554. void Parser::Act$rule_number(void)
  555. {
  556.     Sym(1) = ast_pool -> NewNullLiteral(Token(1));
  557. }
  558. ./
  559.  
  560. BooleanLiteral ::= true
  561. \:$action:\
  562. /.$location
  563. void Parser::Act$rule_number(void)
  564. {
  565.     Sym(1) = ast_pool -> NewTrueLiteral(Token(1));
  566. }
  567. ./
  568.  
  569. BooleanLiteral ::= false
  570. \:$action:\
  571. /.$location
  572. void Parser::Act$rule_number(void)
  573. {
  574.     Sym(1) = ast_pool -> NewFalseLiteral(Token(1));
  575. }
  576. ./
  577.  
  578. --18.4 Productions from 4: Types, Values and Variables
  579.  
  580. Type -> PrimitiveType
  581. \:$NoAction:\
  582. /.$shared_NoAction./
  583.  
  584. Type -> ReferenceType
  585. \:$NoAction:\
  586. /.$shared_NoAction./
  587.  
  588. PrimitiveType -> NumericType
  589. \:$NoAction:\
  590. /.$shared_NoAction./
  591.  
  592. PrimitiveType ::= 'boolean'
  593. \:$action:\
  594. /.$location
  595. void Parser::Act$rule_number(void)
  596. {
  597.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::BOOLEAN, Token(1));
  598. }
  599. ./
  600.  
  601. NumericType -> IntegralType
  602. \:$NoAction:\
  603. /.$shared_NoAction./
  604.  
  605. NumericType -> FloatingPointType
  606. \:$NoAction:\
  607. /.$shared_NoAction./
  608.  
  609. IntegralType ::= 'byte'
  610. \:$action:\
  611. /.$location
  612. void Parser::Act$rule_number(void)
  613. {
  614.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::BYTE, Token(1));
  615. }
  616. ./
  617.  
  618. IntegralType ::= 'short'
  619. \:$action:\
  620. /.$location
  621. void Parser::Act$rule_number(void)
  622. {
  623.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::SHORT, Token(1));
  624. }
  625. ./
  626.  
  627. IntegralType ::= 'int'
  628. \:$action:\
  629. /.$location
  630. void Parser::Act$rule_number(void)
  631. {
  632.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::INT, Token(1));
  633. }
  634. ./
  635.  
  636. IntegralType ::= 'long'
  637. \:$action:\
  638. /.$location
  639. void Parser::Act$rule_number(void)
  640. {
  641.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::LONG, Token(1));
  642. }
  643. ./
  644.  
  645. IntegralType ::= 'char'
  646. \:$action:\
  647. /.$location
  648. void Parser::Act$rule_number(void)
  649. {
  650.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::CHAR, Token(1));
  651. }
  652. ./
  653.  
  654. FloatingPointType ::= 'float'
  655. \:$action:\
  656. /.$location
  657. void Parser::Act$rule_number(void)
  658. {
  659.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::FLOAT, Token(1));
  660. }
  661. ./
  662.  
  663. FloatingPointType ::= 'double'
  664. \:$action:\
  665. /.$location
  666. void Parser::Act$rule_number(void)
  667. {
  668.     Sym(1) = ast_pool -> NewPrimitiveType(Ast::DOUBLE, Token(1));
  669. }
  670. ./
  671.  
  672. ReferenceType -> ClassOrInterfaceType
  673. \:$NoAction:\
  674. /.$shared_NoAction./
  675.  
  676. ReferenceType -> ArrayType
  677. \:$NoAction:\
  678. /.$shared_NoAction./
  679.  
  680. ClassOrInterfaceType -> Name
  681. \:$NoAction:\
  682. /.$shared_NoAction./
  683.  
  684. --
  685. -- These rules have been rewritten to avoid some conflicts introduced
  686. -- by adding the 1.1 features
  687. --
  688. -- ArrayType ::= PrimitiveType '[' ']'
  689. -- ArrayType ::= Name '[' ']'
  690. -- ArrayType ::= ArrayType '[' ']'
  691. --
  692. ArrayType ::= PrimitiveType Dims
  693. \:$MakeArrayType:\
  694. /.$location
  695. void Parser::MakeArrayType(void)
  696. {
  697.     AstArrayType *p = ast_pool -> NewArrayType();
  698.     p -> type     = Sym(1);
  699.     //
  700.     // The list of modifiers is guaranteed not empty
  701.     //
  702.     {
  703.         AstListNode *tail = (AstListNode *) Sym(2);
  704.         p -> AllocateBrackets(tail -> index + 1);
  705.         AstListNode *root = tail;
  706.         do
  707.         {
  708.             root = root -> next;
  709.             p -> AddBrackets((AstBrackets *) root -> element);
  710.         } while(root != tail);
  711.         FreeCircularList(tail);
  712.     }
  713.     Sym(1) = p;
  714. }
  715. ./
  716.  
  717. ArrayType ::= Name Dims
  718. \:$MakeArrayType:\
  719. /.$shared_function
  720. //
  721. // void MakeArrayType(void);
  722. //./
  723.  
  724. ClassType -> ClassOrInterfaceType
  725. \:$NoAction:\
  726. /.$shared_NoAction./
  727.  
  728. InterfaceType -> ClassOrInterfaceType
  729. \:$NoAction:\
  730. /.$shared_NoAction./
  731.  
  732. --18.5 Productions from 6: Names
  733.  
  734. Name -> SimpleName
  735. \:$NoAction:\
  736. /.$shared_NoAction./
  737.  
  738. Name -> QualifiedName
  739. \:$NoAction:\
  740. /.$shared_NoAction./
  741.  
  742. SimpleName ::= 'Identifier'
  743. \:$MakeSimpleName:\
  744. /.$location
  745. void Parser::MakeSimpleName(void)
  746. {
  747.     Sym(1) = ast_pool -> NewSimpleName(Token(1));
  748. }
  749. ./
  750.  
  751. QualifiedName ::= Name '.' 'Identifier'
  752. \:$MakeFieldAccess:\
  753. /.$location
  754. void Parser::MakeFieldAccess(void)
  755. {
  756.     AstFieldAccess *p = ast_pool -> NewFieldAccess();
  757.     p -> base = (AstExpression *) Sym(1);
  758.     p -> dot_token = Token(2);
  759.     p -> identifier_token = Token(3);
  760.     Sym(1) = p;
  761. }
  762. ./
  763.  
  764. --18.6 Productions from 7: Packages
  765.  
  766. CompilationUnit ::= PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt
  767. \:$action:\
  768. /.$location
  769. void Parser::Act$rule_number(void)
  770. {
  771.     AstCompilationUnit *p = ast_pool -> NewCompilationUnit();
  772.     p -> package_declaration_opt = (AstPackageDeclaration *) Sym(1);
  773.     if (Sym(2) != NULL)
  774.     {
  775.         AstListNode *tail = (AstListNode *) Sym(2);
  776.         p -> AllocateImportDeclarations(tail -> index + 1);
  777.         AstListNode *root = tail;
  778.         do
  779.         {
  780.             root = root -> next;
  781.             p -> AddImportDeclaration((AstImportDeclaration *) root -> element);
  782.         } while(root != tail);
  783.         FreeCircularList(tail);
  784.     }
  785.     if (Sym(3) != NULL)
  786.     {
  787.         AstListNode *tail = (AstListNode *) Sym(3);
  788.         p -> AllocateTypeDeclarations(tail -> index + 1);
  789.         AstListNode *root = tail;
  790.         do
  791.         {
  792.             root = root -> next;
  793.             p -> AddTypeDeclaration(root -> element);
  794.         } while(root != tail);
  795.         FreeCircularList(tail);
  796.     }
  797.     Sym(1) = p;
  798. }
  799. ./
  800.  
  801. ImportDeclarations ::= ImportDeclaration
  802. \:$action:\
  803. /.$location
  804. //
  805. // Note that the list is circular so as to preserve the order of the elements
  806. //
  807. void Parser::Act$rule_number(void)
  808. {
  809.     AstListNode *p = AllocateListNode();
  810.     p -> next = p;
  811.     p -> element = Sym(1);
  812.     p -> index = 0;
  813.  
  814.     Sym(1) = p;
  815. }
  816. ./
  817.  
  818. ImportDeclarations ::= ImportDeclarations ImportDeclaration
  819. \:$action:\
  820. /.$location
  821. //
  822. // Note that the list is circular so as to preserve the order of the elements
  823. //
  824. void Parser::Act$rule_number(void)
  825. {
  826.     AstListNode *tail = (AstListNode *) Sym(1);
  827.  
  828.     AstListNode *p = AllocateListNode();
  829.     p -> element = Sym(2);
  830.     p -> index = tail -> index + 1;
  831.  
  832.     p -> next = tail -> next;
  833.     tail -> next = p;
  834.  
  835.     Sym(1) = p;
  836. }
  837. ./
  838.  
  839. TypeDeclarations ::= TypeDeclaration
  840. \:$action:\
  841. /.$location
  842. //
  843. // Note that the list is circular so as to preserve the order of the elements
  844. //
  845. void Parser::Act$rule_number(void)
  846. {
  847.     AstListNode *p = AllocateListNode();
  848.     p -> next = p;
  849.     p -> element = Sym(1);
  850.     p -> index = 0;
  851.  
  852.     Sym(1) = p;
  853. }
  854. ./
  855.  
  856. TypeDeclarations ::= TypeDeclarations TypeDeclaration
  857. \:$action:\
  858. /.$location
  859. //
  860. // Note that the list is circular so as to preserve the order of the elements
  861. //
  862. void Parser::Act$rule_number(void)
  863. {
  864.     AstListNode *tail = (AstListNode *) Sym(1);
  865.  
  866.     AstListNode *p = AllocateListNode();
  867.     p -> element = Sym(2);
  868.     p -> index = tail -> index + 1;
  869.  
  870.     p -> next = tail -> next;
  871.     tail -> next = p;
  872.  
  873.     Sym(1) = p;
  874. }
  875. ./
  876.  
  877. PackageDeclaration ::= 'package' Name PackageHeaderMarker ';'
  878. \:$action:\
  879. /.$location
  880. void Parser::Act$rule_number(void)
  881. {
  882.     AstPackageDeclaration *p = ast_pool -> NewPackageDeclaration();
  883.     p -> package_token   = Token(1);
  884.     p -> name            = (AstExpression *) Sym(2);
  885.     p -> semicolon_token = Token(3);
  886.     Sym(1) = p;
  887. }
  888. ./
  889.  
  890. ImportDeclaration -> SingleTypeImportDeclaration
  891. \:$NoAction:\
  892. /.$shared_NoAction./
  893.  
  894. ImportDeclaration -> TypeImportOnDemandDeclaration
  895. \:$NoAction:\
  896. /.$shared_NoAction./
  897.  
  898. SingleTypeImportDeclaration ::= 'import' Name ';'
  899. \:$action:\
  900. /.$location
  901. void Parser::Act$rule_number(void)
  902. {
  903.     AstImportDeclaration *p = ast_pool -> NewImportDeclaration();
  904.     p -> import_token    = Token(1);
  905.     p -> name            = (AstExpression *) Sym(2);
  906.     p -> star_token_opt  = 0;
  907.     p -> semicolon_token = Token(3);
  908.     Sym(1) = p;
  909. }
  910. ./
  911.  
  912. TypeImportOnDemandDeclaration ::= 'import' Name '.' '*' ';'
  913. \:$action:\
  914. /.$location
  915. void Parser::Act$rule_number(void)
  916. {
  917.     AstImportDeclaration *p = ast_pool -> NewImportDeclaration();
  918.     p -> import_token         = Token(1);
  919.     p -> name                 = (AstExpression *) Sym(2);
  920.     p -> star_token_opt       = Token(4);
  921.     p -> semicolon_token      = Token(5);
  922.     Sym(1) = p;
  923. }
  924. ./
  925.  
  926. TypeDeclaration -> ClassDeclaration
  927. \:$NoAction:\
  928. /.$shared_NoAction./
  929.  
  930. TypeDeclaration -> InterfaceDeclaration
  931. \:$NoAction:\
  932. /.$shared_NoAction./
  933.  
  934. TypeDeclaration ::= ';'
  935. \:$action:\
  936. /.$location
  937. void Parser::Act$rule_number(void)
  938. {
  939.     Sym(1) = ast_pool -> NewEmptyDeclaration(Token(1));
  940. }
  941. ./
  942.  
  943. --18.7 Only in the LALR(1) Grammar
  944.  
  945. Modifiers ::= Modifier
  946. \:$action:\
  947. /.$location
  948. //
  949. // Note that the list is circular so as to preserve the order of the elements
  950. //
  951. void Parser::Act$rule_number(void)
  952. {
  953.     AstListNode *p = AllocateListNode();
  954.     p -> next = p;
  955.     p -> element = Sym(1);
  956.     p -> index = 0;
  957.  
  958.     Sym(1) = p;
  959. }
  960. ./
  961.  
  962. Modifiers ::= Modifiers Modifier
  963. \:$action:\
  964. /.$location
  965. //
  966. // Note that the list is circular so as to preserve the order of the elements
  967. //
  968. void Parser::Act$rule_number(void)
  969. {
  970.     AstListNode *tail = (AstListNode *) Sym(1);
  971.  
  972.     AstListNode *p = AllocateListNode();
  973.     p -> element = Sym(2);
  974.     p -> index = tail -> index + 1;
  975.  
  976.     p -> next = tail -> next;
  977.     tail -> next = p;
  978.  
  979.     Sym(1) = p;
  980. }
  981. ./
  982.  
  983. Modifier ::= 'public'
  984. \:$action:\
  985. /.$location
  986. void Parser::Act$rule_number(void)
  987. {
  988.     Sym(1) = ast_pool -> NewModifier(Ast::PUBLIC, Token(1));
  989. }
  990. ./
  991.  
  992. Modifier ::= 'protected'
  993. \:$action:\
  994. /.$location
  995. void Parser::Act$rule_number(void)
  996. {
  997.     Sym(1) = ast_pool -> NewModifier(Ast::PROTECTED, Token(1));
  998. }
  999. ./
  1000.  
  1001. Modifier ::= 'private'
  1002. \:$action:\
  1003. /.$location
  1004. void Parser::Act$rule_number(void)
  1005. {
  1006.     Sym(1) = ast_pool -> NewModifier(Ast::PRIVATE, Token(1));
  1007. }
  1008. ./
  1009.  
  1010. Modifier ::= 'static'
  1011. \:$action:\
  1012. /.$location
  1013. void Parser::Act$rule_number(void)
  1014. {
  1015.     Sym(1) = ast_pool -> NewModifier(Ast::STATIC, Token(1));
  1016. }
  1017. ./
  1018.  
  1019. Modifier ::= 'abstract'
  1020. \:$action:\
  1021. /.$location
  1022. void Parser::Act$rule_number(void)
  1023. {
  1024.     Sym(1) = ast_pool -> NewModifier(Ast::ABSTRACT, Token(1));
  1025. }
  1026. ./
  1027.  
  1028. Modifier ::= 'final'
  1029. \:$action:\
  1030. /.$location
  1031. void Parser::Act$rule_number(void)
  1032. {
  1033.     Sym(1) = ast_pool -> NewModifier(Ast::FINAL, Token(1));
  1034. }
  1035. ./
  1036.  
  1037. Modifier ::= 'native'
  1038. \:$action:\
  1039. /.$location
  1040. void Parser::Act$rule_number(void)
  1041. {
  1042.     Sym(1) = ast_pool -> NewModifier(Ast::NATIVE, Token(1));
  1043. }
  1044. ./
  1045.  
  1046. Modifier ::= 'strictfp'
  1047. \:$action:\
  1048. /.$location
  1049. void Parser::Act$rule_number(void)
  1050. {
  1051.     Sym(1) = ast_pool -> NewModifier(Ast::STRICTFP, Token(1));
  1052. }
  1053. ./
  1054.  
  1055. Modifier ::= 'synchronized'
  1056. \:$action:\
  1057. /.$location
  1058. void Parser::Act$rule_number(void)
  1059. {
  1060.     Sym(1) = ast_pool -> NewModifier(Ast::SYNCHRONIZED, Token(1));
  1061. }
  1062. ./
  1063.  
  1064. Modifier ::= 'transient'
  1065. \:$action:\
  1066. /.$location
  1067. void Parser::Act$rule_number(void)
  1068. {
  1069.     Sym(1) = ast_pool -> NewModifier(Ast::TRANSIENT, Token(1));
  1070. }
  1071. ./
  1072.  
  1073. Modifier ::= 'volatile'
  1074. \:$action:\
  1075. /.$location
  1076. void Parser::Act$rule_number(void)
  1077. {
  1078.     Sym(1) = ast_pool -> NewModifier(Ast::VOLATILE, Token(1));
  1079. }
  1080. ./
  1081.  
  1082. --18.8 Productions from 8: Class Declarations
  1083. --ClassModifier ::=
  1084. --      'abstract'
  1085. --    | 'final'
  1086. --    | 'public'
  1087. --18.8.1 Productions from 8.1: Class Declarations
  1088.  
  1089. ClassDeclaration ::= Modifiersopt 'class' 'Identifier' Superopt Interfacesopt ClassBody
  1090. \:$action:\
  1091. /.$location
  1092. void Parser::Act$rule_number(void)
  1093. {
  1094.     AstClassDeclaration *p = ast_pool -> NewClassDeclaration();
  1095.     if (Sym(1) != NULL)
  1096.     {
  1097.         AstListNode *tail = (AstListNode *) Sym(1);
  1098.         p -> AllocateClassModifiers(tail -> index + 1);
  1099.         AstListNode *root = tail;
  1100.         do
  1101.         {
  1102.             root = root -> next;
  1103.             p -> AddClassModifier((AstModifier *) root -> element);
  1104.         } while(root != tail);
  1105.         FreeCircularList(tail);
  1106.     }
  1107.     p -> class_token          = Token(2);
  1108.     p -> identifier_token     = Token(3);
  1109.     p -> super_opt            = (AstExpression *) Sym(4);
  1110.     if (Sym(5) != NULL)
  1111.     {
  1112.         AstListNode *tail = (AstListNode *) Sym(5);
  1113.         p -> AllocateInterfaces(tail -> index + 1);
  1114.         AstListNode *root = tail;
  1115.         do
  1116.         {
  1117.             root = root -> next;
  1118.             p -> AddInterface((AstExpression *) root -> element);
  1119.         } while(root != tail);
  1120.         FreeCircularList(tail);
  1121.     }
  1122.     p -> class_body = (AstClassBody *) Sym(6);
  1123.     Sym(1) = p;
  1124. }
  1125. ./
  1126.  
  1127. Super ::= 'extends' ClassType
  1128. \:$SetSym1ToSym2:\
  1129. /.$location
  1130. void Parser::SetSym1ToSym2(void) { Sym(1) = Sym(2); }
  1131. ./
  1132.  
  1133. Interfaces ::= 'implements' InterfaceTypeList
  1134. \:$SetSym1ToSym2:\
  1135. /.$shared_function
  1136. //
  1137. // void SetSym1ToSym2(void);
  1138. //./
  1139.  
  1140. InterfaceTypeList ::= InterfaceType
  1141. \:$action:\
  1142. /.$location
  1143. //
  1144. // Note that the list is circular so as to preserve the order of the elements
  1145. //
  1146. void Parser::Act$rule_number(void)
  1147. {
  1148.     AstListNode *p = AllocateListNode();
  1149.     p -> next = p;
  1150.     p -> element = Sym(1);
  1151.     p -> index = 0;
  1152.  
  1153.     Sym(1) = p;
  1154. }
  1155. ./
  1156.  
  1157. InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
  1158. \:$action:\
  1159. /.$location
  1160. //
  1161. // Note that the list is circular so as to preserve the order of the elements
  1162. //
  1163. void Parser::Act$rule_number(void)
  1164. {
  1165.     AstListNode *tail = (AstListNode *) Sym(1);
  1166.  
  1167.     AstListNode *p = AllocateListNode();
  1168.     p -> element = Sym(3);
  1169.     p -> index = tail -> index + 1;
  1170.  
  1171.     p -> next = tail -> next;
  1172.     tail -> next = p;
  1173.  
  1174.     Sym(1) = p;
  1175. }
  1176. ./
  1177.  
  1178. ClassBody ::= '{' ClassBodyDeclarationsopt '}'
  1179. \:$action:\
  1180. /.$location
  1181. void Parser::Act$rule_number(void)
  1182. {
  1183.     AstClassBody *p = ast_pool -> NewClassBody();
  1184.     if (parse_header_only)
  1185.         p -> mark_unparsed();
  1186.  
  1187.     p -> left_brace_token = Token(1);
  1188.     if (Sym(2) != NULL)
  1189.     {
  1190.         int num_instance_variables = 0,
  1191.             num_class_variables = 0,
  1192.             num_methods = 0,
  1193.             num_constructors = 0,
  1194.             num_static_initializers = 0,
  1195.             num_inner_classes = 0,
  1196.             num_inner_interfaces = 0,
  1197.             num_blocks = 0,
  1198.             num_empty_declarations = 0;
  1199.  
  1200.         AstListNode *tail = (AstListNode *) Sym(2);
  1201.         p -> AllocateClassBodyDeclarations(tail -> index + 1);
  1202.         AstListNode *root = tail;
  1203.         do
  1204.         {
  1205.             root = root -> next;
  1206.             p -> AddClassBodyDeclaration(root -> element);
  1207.  
  1208.             AstFieldDeclaration *field_declaration = root -> element -> FieldDeclarationCast();
  1209.             if (field_declaration)
  1210.             {
  1211.                 for (int i = 0; i < field_declaration -> NumVariableModifiers(); i++)
  1212.                 {
  1213.                     if (field_declaration -> VariableModifier(i) -> kind == Ast::STATIC)
  1214.                     {
  1215.                         field_declaration -> MarkStatic();
  1216.                         break;
  1217.                     }
  1218.                 }
  1219.                 if (field_declaration -> StaticFieldCast())
  1220.                      num_class_variables++;
  1221.                 else num_instance_variables++;
  1222.             }
  1223.             else if (root -> element -> MethodDeclarationCast())
  1224.             {
  1225.                 num_methods++;
  1226.             }
  1227.             else if (root -> element -> ConstructorDeclarationCast())
  1228.             {
  1229.                 num_constructors++;
  1230.             }
  1231.             else if (root -> element -> StaticInitializerCast())
  1232.             {
  1233.                 num_static_initializers++;
  1234.             }
  1235.             else if (root -> element -> ClassDeclarationCast())
  1236.             {
  1237.                 num_inner_classes++;
  1238.             }
  1239.             else if (root -> element -> InterfaceDeclarationCast())
  1240.             {
  1241.                 num_inner_interfaces++;
  1242.             }
  1243.             else if (root -> element -> BlockCast())
  1244.             {
  1245.                 num_blocks++;
  1246.             }
  1247.             else num_empty_declarations++;
  1248.         } while(root != tail);
  1249.  
  1250.         p -> AllocateInstanceVariables(num_instance_variables);
  1251.         p -> AllocateClassVariables(num_class_variables);
  1252.         p -> AllocateMethods(num_methods);
  1253.         p -> AllocateConstructors(num_constructors);
  1254.         p -> AllocateStaticInitializers(num_static_initializers);
  1255.         p -> AllocateNestedClasses(num_inner_classes);
  1256.         p -> AllocateNestedInterfaces(num_inner_interfaces);
  1257.         p -> AllocateBlocks(num_blocks);
  1258.         p -> AllocateEmptyDeclarations(num_empty_declarations);
  1259.  
  1260.         root = tail;
  1261.         do
  1262.         {
  1263.             root = root -> next;
  1264.  
  1265.             AstFieldDeclaration *field_declaration;
  1266.             AstMethodDeclaration *method_declaration;
  1267.             AstConstructorDeclaration *constructor_declaration;
  1268.             AstStaticInitializer *static_initializer;
  1269.             AstClassDeclaration *class_declaration;
  1270.             AstInterfaceDeclaration *interface_declaration;
  1271.             AstBlock *block;
  1272.  
  1273.             if ((field_declaration = root -> element -> FieldDeclarationCast()))
  1274.             {
  1275.                 if (field_declaration -> StaticFieldCast())
  1276.                      p -> AddClassVariable(field_declaration);
  1277.                 else p -> AddInstanceVariable(field_declaration);
  1278.             }
  1279.             else if ((method_declaration = root -> element -> MethodDeclarationCast()))
  1280.             {
  1281.                 p -> AddMethod(method_declaration);
  1282.             }
  1283.             else if ((constructor_declaration = root -> element -> ConstructorDeclarationCast()))
  1284.             {
  1285.                 p -> AddConstructor(constructor_declaration);
  1286.             }
  1287.             else if ((static_initializer = root -> element -> StaticInitializerCast()))
  1288.             {
  1289.                 p -> AddStaticInitializer(static_initializer);
  1290.             }
  1291.             else if ((class_declaration = root -> element -> ClassDeclarationCast()))
  1292.             {
  1293.                 p -> AddNestedClass(class_declaration);
  1294.             }
  1295.             else if ((interface_declaration = root -> element -> InterfaceDeclarationCast()))
  1296.             {
  1297.                 p -> AddNestedInterface(interface_declaration);
  1298.             }
  1299.             else if ((block = root -> element -> BlockCast()))
  1300.             {
  1301.                 p -> AddBlock(block);
  1302.             }
  1303.             else // assert(block = root -> element -> EmptyDeclarationCast())
  1304.             {
  1305.                 p -> AddEmptyDeclaration((AstEmptyDeclaration *) root -> element);
  1306.             }
  1307.         } while(root != tail);
  1308.         FreeCircularList(tail);
  1309.     }
  1310.     p -> right_brace_token = Token(3);
  1311.     p -> pool = body_pool; // from now on, this is the storage pool to use for this type
  1312.     Sym(1) = p;
  1313. }
  1314. ./
  1315.  
  1316. ClassBodyDeclarations ::= ClassBodyDeclaration
  1317. \:$action:\
  1318. /.$location
  1319. //
  1320. // Note that the list is circular so as to preserve the order of the elements
  1321. //
  1322. void Parser::Act$rule_number(void)
  1323. {
  1324.     AstListNode *p = AllocateListNode();
  1325.     p -> next = p;
  1326.     p -> element = Sym(1);
  1327.     p -> index = 0;
  1328.  
  1329.     Sym(1) = p;
  1330. }
  1331. ./
  1332.  
  1333. ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
  1334. \:$action:\
  1335. /.$location
  1336. //
  1337. // Note that the list is circular so as to preserve the order of the elements
  1338. //
  1339. void Parser::Act$rule_number(void)
  1340. {
  1341.     AstListNode *tail = (AstListNode *) Sym(1);
  1342.  
  1343.     AstListNode *p = AllocateListNode();
  1344.     p -> element = Sym(2);
  1345.     p -> index = tail -> index + 1;
  1346.  
  1347.     p -> next = tail -> next;
  1348.     tail -> next = p;
  1349.  
  1350.     Sym(1) = p;
  1351. }
  1352. ./
  1353.  
  1354. ClassBodyDeclaration -> ClassMemberDeclaration
  1355. \:$NoAction:\
  1356. /.$shared_NoAction./
  1357.  
  1358. ClassBodyDeclaration -> StaticInitializer
  1359. \:$NoAction:\
  1360. /.$shared_NoAction./
  1361.  
  1362. ClassBodyDeclaration -> ConstructorDeclaration
  1363. \:$NoAction:\
  1364. /.$shared_NoAction./
  1365.  
  1366. --1.1 feature
  1367. ClassBodyDeclaration ::= MethodHeaderMarker Block
  1368. \:$action:\
  1369. /.$location
  1370. void Parser::Act$rule_number(void)
  1371. {
  1372.     Sym(1) = Sym(2);
  1373. }
  1374. ./
  1375.  
  1376. ClassMemberDeclaration -> FieldDeclaration
  1377. \:$NoAction:\
  1378. /.$shared_NoAction./
  1379.  
  1380. ClassMemberDeclaration -> MethodDeclaration
  1381. \:$NoAction:\
  1382. /.$shared_NoAction./
  1383.  
  1384. --1.1 feature
  1385. ClassMemberDeclaration -> ClassDeclaration
  1386. \:$NoAction:\
  1387. /.$shared_NoAction./
  1388.  
  1389. --1.1 feature
  1390. ClassMemberDeclaration -> InterfaceDeclaration
  1391. \:$NoAction:\
  1392. /.$shared_NoAction./
  1393.  
  1394. --
  1395. -- Empty declarations are not valid Java ClassMemberDeclarations.
  1396. -- However, since the current (2/14/97) Java compiler accepts them
  1397. -- (in fact, some of the official tests contain this erroneous
  1398. -- syntax), we decided to accept them as valid syntax and flag them
  1399. -- as a warning during semantic processing.
  1400. --
  1401. ClassMemberDeclaration ::= ';'
  1402. \:$action:\
  1403. /.$location
  1404. void Parser::Act$rule_number(void)
  1405. {
  1406.     Sym(1) = ast_pool -> NewEmptyDeclaration(Token(1));
  1407. }
  1408. ./
  1409.  
  1410. --18.8.2 Productions from 8.3: Field Declarations
  1411. --VariableModifier ::=
  1412. --      'public'
  1413. --    | 'protected'
  1414. --    | 'private'
  1415. --    | 'static'
  1416. --    | 'final'
  1417. --    | 'transient'
  1418. --    | 'volatile'
  1419.  
  1420. FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
  1421. \:$action:\
  1422. /.$location
  1423. void Parser::Act$rule_number(void)
  1424. {
  1425.     AstFieldDeclaration *p = ast_pool -> NewFieldDeclaration();
  1426.     if (Sym(1) != NULL)
  1427.     {
  1428.         AstListNode *tail = (AstListNode *) Sym(1);
  1429.         p -> AllocateVariableModifiers(tail -> index + 1);
  1430.         AstListNode *root = tail;
  1431.         do
  1432.         {
  1433.             root = root -> next;
  1434.             p -> AddVariableModifier((AstModifier *) root -> element);
  1435.         } while(root != tail);
  1436.         FreeCircularList(tail);
  1437.     }
  1438.     p -> type = Sym(2);
  1439.     //
  1440.     // The list of declarators is guaranteed not empty
  1441.     //
  1442.     {
  1443.         AstListNode *tail = (AstListNode *) Sym(3);
  1444.         p -> AllocateVariableDeclarators(tail -> index + 1);
  1445.         AstListNode *root = tail;
  1446.         do
  1447.         {
  1448.             root = root -> next;
  1449.             p -> AddVariableDeclarator((AstVariableDeclarator *) root -> element);
  1450.         } while(root != tail);
  1451.         FreeCircularList(tail);
  1452.     }
  1453.     p -> semicolon_token      = Token(4);
  1454.     Sym(1) = p;
  1455. }
  1456. ./
  1457.  
  1458. VariableDeclarators ::= VariableDeclarator
  1459. \:$action:\
  1460. /.$location
  1461. //
  1462. // Note that the list is circular so as to preserve the order of the elements
  1463. //
  1464. void Parser::Act$rule_number(void)
  1465. {
  1466.     AstListNode *p = AllocateListNode();
  1467.     p -> next = p;
  1468.     p -> element = Sym(1);
  1469.     p -> index = 0;
  1470.  
  1471.     Sym(1) = p;
  1472. }
  1473. ./
  1474.  
  1475. VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator
  1476. \:$action:\
  1477. /.$location
  1478. //
  1479. // Note that the list is circular so as to preserve the order of the elements
  1480. //
  1481. void Parser::Act$rule_number(void)
  1482. {
  1483.     AstListNode *tail = (AstListNode *) Sym(1);
  1484.  
  1485.     AstListNode *p = AllocateListNode();
  1486.     p -> element = Sym(3);
  1487.     p -> index = tail -> index + 1;
  1488.  
  1489.     p -> next = tail -> next;
  1490.     tail -> next = p;
  1491.  
  1492.     Sym(1) = p;
  1493. }
  1494. ./
  1495.  
  1496. VariableDeclarator ::= VariableDeclaratorId
  1497. \:$action:\
  1498. /.$location
  1499. void Parser::Act$rule_number(void)
  1500. {
  1501.     AstVariableDeclarator *p = ast_pool -> NewVariableDeclarator();
  1502.     p -> variable_declarator_name = (AstVariableDeclaratorId *) Sym(1);
  1503.     p -> variable_initializer_opt = NULL;
  1504.     Sym(1) = p;
  1505. }
  1506. ./
  1507.  
  1508. VariableDeclarator ::= VariableDeclaratorId '=' VariableInitializer
  1509. \:$action:\
  1510. /.$location
  1511. void Parser::Act$rule_number(void)
  1512. {
  1513.     AstVariableDeclarator *p = ast_pool -> NewVariableDeclarator();
  1514.     p -> variable_declarator_name = (AstVariableDeclaratorId *) Sym(1);
  1515.     p -> variable_initializer_opt = Sym(3);
  1516.     Sym(1) = p;
  1517. }
  1518. ./
  1519.  
  1520. VariableDeclaratorId ::= 'Identifier' Dimsopt
  1521. \:$action:\
  1522. /.$location
  1523. void Parser::Act$rule_number(void)
  1524. {
  1525.     AstVariableDeclaratorId *p = ast_pool -> NewVariableDeclaratorId();
  1526.     p -> identifier_token = Token(1);
  1527.     if (Sym(2) != NULL)
  1528.     {
  1529.         AstListNode *tail = (AstListNode *) Sym(2);
  1530.         p -> AllocateBrackets(tail -> index + 1);
  1531.         AstListNode *root = tail;
  1532.         do
  1533.         {
  1534.             root = root -> next;
  1535.             p -> AddBrackets((AstBrackets *) root -> element);
  1536.         } while(root != tail);
  1537.         FreeCircularList(tail);
  1538.     }
  1539.     Sym(1) = p;
  1540. }
  1541. ./
  1542.  
  1543. VariableInitializer -> Expression
  1544. \:$NoAction:\
  1545. /.$shared_NoAction./
  1546.  
  1547. VariableInitializer -> ArrayInitializer
  1548. \:$NoAction:\
  1549. /.$shared_NoAction./
  1550.  
  1551. --18.8.3 Productions from 8.4: Method Declarations
  1552. --MethodModifier ::=
  1553. --      'public'
  1554. --    | 'protected'
  1555. --    | 'private'
  1556. --    | 'static'
  1557. --    | 'abstract'
  1558. --    | 'final'
  1559. --    | 'native'
  1560. --    | 'synchronized'
  1561. --
  1562. -- The original rule does not contain the "MethodHeaderMarker.
  1563. -- See explanation above.
  1564. --
  1565. -- MethodDeclaration ::= MethodHeader MethodBody
  1566. --
  1567.  
  1568. MethodDeclaration ::= MethodHeader MethodHeaderMarker MethodBody
  1569. \:$action:\
  1570. /.$location
  1571. void Parser::Act$rule_number(void)
  1572. {
  1573.     ((AstMethodDeclaration *) Sym(1)) -> method_body = (AstStatement *) Sym(3);
  1574. }
  1575. ./
  1576.  
  1577. MethodHeader ::= Modifiersopt Type MethodDeclarator Throwsopt
  1578. \:$action:\
  1579. /.$location
  1580. void Parser::Act$rule_number(void)
  1581. {
  1582.     AstMethodDeclaration *p = ast_pool -> NewMethodDeclaration();
  1583.     if (Sym(1) != NULL)
  1584.     {
  1585.         AstListNode *tail = (AstListNode *) Sym(1);
  1586.         p -> AllocateMethodModifiers(tail -> index + 1);
  1587.         AstListNode *root = tail;
  1588.         do
  1589.         {
  1590.             root = root -> next;
  1591.             p -> AddMethodModifier((AstModifier *) root -> element);
  1592.         } while(root != tail);
  1593.         FreeCircularList(tail);
  1594.     }
  1595.     p -> type              = Sym(2);
  1596.     p -> method_declarator = (AstMethodDeclarator *) Sym(3);
  1597.     if (Sym(4) != NULL)
  1598.     {
  1599.         AstListNode *tail = (AstListNode *) Sym(4);
  1600.         p -> AllocateThrows(tail -> index + 1);
  1601.         AstListNode *root = tail;
  1602.         do
  1603.         {
  1604.             root = root -> next;
  1605.             p -> AddThrow((AstExpression *) root -> element);
  1606.         } while(root != tail);
  1607.         FreeCircularList(tail);
  1608.     }
  1609.     Sym(1) = p;
  1610. }
  1611. ./
  1612.  
  1613. MethodHeader ::= Modifiersopt 'void' MethodDeclarator Throwsopt
  1614. \:$action:\
  1615. /.$location
  1616. void Parser::Act$rule_number(void)
  1617. {
  1618.     AstMethodDeclaration *p = ast_pool -> NewMethodDeclaration();
  1619.     if (Sym(1) != NULL)
  1620.     {
  1621.         AstListNode *tail = (AstListNode *) Sym(1);
  1622.         p -> AllocateMethodModifiers(tail -> index + 1);
  1623.         AstListNode *root = tail;
  1624.         do
  1625.         {
  1626.             root = root -> next;
  1627.             p -> AddMethodModifier((AstModifier *) root -> element);
  1628.         } while(root != tail);
  1629.         FreeCircularList(tail);
  1630.     }
  1631.     p -> type              = ast_pool -> NewPrimitiveType(Ast::VOID_TYPE, Token(2));
  1632.     p -> method_declarator = (AstMethodDeclarator *) Sym(3);
  1633.     if (Sym(4) != NULL)
  1634.     {
  1635.         AstListNode *tail = (AstListNode *) Sym(4);
  1636.         p -> AllocateThrows(tail -> index + 1);
  1637.         AstListNode *root = tail;
  1638.         do
  1639.         {
  1640.             root = root -> next;
  1641.             p -> AddThrow((AstExpression *) root -> element);
  1642.         } while(root != tail);
  1643.         FreeCircularList(tail);
  1644.     }
  1645.     Sym(1) = p;
  1646. }
  1647. ./
  1648.  
  1649. MethodDeclarator ::= 'Identifier' '(' FormalParameterListopt ')' Dimsopt
  1650. \:$action:\
  1651. /.$location
  1652. void Parser::Act$rule_number(void)
  1653. {
  1654.     AstMethodDeclarator *p = ast_pool -> NewMethodDeclarator();
  1655.     p -> identifier_token        = Token(1);
  1656.     p -> left_parenthesis_token  = Token(2);
  1657.     if (Sym(3) != NULL)
  1658.     {
  1659.         AstListNode *tail = (AstListNode *) Sym(3);
  1660.         p -> AllocateFormalParameters(tail -> index + 1);
  1661.         AstListNode *root = tail;
  1662.         do
  1663.         {
  1664.             root = root -> next;
  1665.             p -> AddFormalParameter((AstFormalParameter *) root -> element);
  1666.         } while(root != tail);
  1667.         FreeCircularList(tail);
  1668.     }
  1669.     p -> right_parenthesis_token = Token(4);
  1670.     if (Sym(5) != NULL)
  1671.     {
  1672.         AstListNode *tail = (AstListNode *) Sym(5);
  1673.         p -> AllocateBrackets(tail -> index + 1);
  1674.         AstListNode *root = tail;
  1675.         do
  1676.         {
  1677.             root = root -> next;
  1678.             p -> AddBrackets((AstBrackets *) root -> element);
  1679.         } while(root != tail);
  1680.         FreeCircularList(tail);
  1681.     }
  1682.     Sym(1) = p;
  1683. }
  1684. ./
  1685.  
  1686. FormalParameterList ::= FormalParameter
  1687. \:$action:\
  1688. /.$location
  1689. //
  1690. // Note that the list is circular so as to preserve the order of the elements
  1691. //
  1692. void Parser::Act$rule_number(void)
  1693. {
  1694.     AstListNode *p = AllocateListNode();
  1695.     p -> next = p;
  1696.     p -> element = Sym(1);
  1697.     p -> index = 0;
  1698.  
  1699.     Sym(1) = p;
  1700. }
  1701. ./
  1702.  
  1703. FormalParameterList ::= FormalParameterList ',' FormalParameter
  1704. \:$action:\
  1705. /.$location
  1706. //
  1707. // Note that the list is circular so as to preserve the order of the elements
  1708. //
  1709. void Parser::Act$rule_number(void)
  1710. {
  1711.     AstListNode *tail = (AstListNode *) Sym(1);
  1712.  
  1713.     AstListNode *p = AllocateListNode();
  1714.     p -> element = Sym(3);
  1715.     p -> index = tail -> index + 1;
  1716.  
  1717.     p -> next = tail -> next;
  1718.     tail -> next = p;
  1719.  
  1720.     Sym(1) = p;
  1721. }
  1722. ./
  1723.  
  1724. FormalParameter ::= Type VariableDeclaratorId
  1725. \:$action:\
  1726. /.$location
  1727. void Parser::Act$rule_number(void)
  1728. {
  1729.     AstFormalParameter *p = ast_pool -> NewFormalParameter();
  1730.     p -> type = Sym(1);
  1731.  
  1732.     AstVariableDeclarator *formal_declarator = ast_pool -> NewVariableDeclarator();
  1733.     formal_declarator -> variable_declarator_name = (AstVariableDeclaratorId *) Sym(2);
  1734.     formal_declarator -> variable_initializer_opt = NULL;
  1735.  
  1736.     p -> formal_declarator = formal_declarator;
  1737.  
  1738.     Sym(1) = p;
  1739. }
  1740. ./
  1741.  
  1742. --1.1 feature
  1743. FormalParameter ::= Modifiers Type VariableDeclaratorId
  1744. \:$action:\
  1745. /.$location
  1746. void Parser::Act$rule_number(void)
  1747. {
  1748.     AstFormalParameter *p = ast_pool -> NewFormalParameter();
  1749.     //
  1750.     // The list of modifiers is guaranteed not empty
  1751.     //
  1752.     {
  1753.         AstListNode *tail = (AstListNode *) Sym(1);
  1754.         p -> AllocateParameterModifiers(tail -> index + 1);
  1755.         AstListNode *root = tail;
  1756.         do
  1757.         {
  1758.             root = root -> next;
  1759.             p -> AddParameterModifier((AstModifier *) root -> element);
  1760.         } while(root != tail);
  1761.         FreeCircularList(tail);
  1762.     }
  1763.  
  1764.     p -> type = Sym(2);
  1765.  
  1766.     AstVariableDeclarator *formal_declarator = ast_pool -> NewVariableDeclarator();
  1767.     formal_declarator -> variable_declarator_name = (AstVariableDeclaratorId *) Sym(3);
  1768.     formal_declarator -> variable_initializer_opt = NULL;
  1769.  
  1770.     p -> formal_declarator = formal_declarator;
  1771.  
  1772.     Sym(1) = p;
  1773. }
  1774. ./
  1775.  
  1776. Throws ::= 'throws' ClassTypeList
  1777. \:$SetSym1ToSym2:\
  1778. /.$shared_function
  1779. //
  1780. // void SetSym1ToSym2(void);
  1781. //./
  1782.  
  1783. ClassTypeList ::= ClassType
  1784. \:$action:\
  1785. /.$location
  1786. //
  1787. // Note that the list is circular so as to preserve the order of the elements
  1788. //
  1789. void Parser::Act$rule_number(void)
  1790. {
  1791.     AstListNode *p = AllocateListNode();
  1792.     p -> next = p;
  1793.     p -> element = Sym(1);
  1794.     p -> index = 0;
  1795.  
  1796.     Sym(1) = p;
  1797. }
  1798. ./
  1799.  
  1800. ClassTypeList ::= ClassTypeList ',' ClassType
  1801. \:$action:\
  1802. /.$location
  1803. //
  1804. // Note that the list is circular so as to preserve the order of the elements
  1805. //
  1806. void Parser::Act$rule_number(void)
  1807. {
  1808.     AstListNode *tail = (AstListNode *) Sym(1);
  1809.  
  1810.     AstListNode *p = AllocateListNode();
  1811.     p -> element = Sym(3);
  1812.     p -> index = tail -> index + 1;
  1813.  
  1814.     p -> next = tail -> next;
  1815.     tail -> next = p;
  1816.  
  1817.     Sym(1) = p;
  1818. }
  1819. ./
  1820.  
  1821. MethodBody -> Block
  1822. \:$NoAction:\
  1823. /.$shared_NoAction./
  1824.  
  1825. MethodBody ::= ';'
  1826. \:$MakeEmptyStatement:\
  1827. /.$location
  1828. void Parser::MakeEmptyStatement(void)
  1829. {
  1830.     Sym(1) = ast_pool -> NewEmptyStatement(Token(1));
  1831. }
  1832. ./
  1833.  
  1834. --18.8.4 Productions from 8.5: Static Initializers
  1835.  
  1836. StaticInitializer ::= 'static' MethodHeaderMarker Block
  1837. \:$action:\
  1838. /.$location
  1839. void Parser::Act$rule_number(void)
  1840. {
  1841.     AstStaticInitializer *p = ast_pool -> NewStaticInitializer();
  1842.     p -> static_token = Token(1);
  1843.     p -> block        = (AstBlock *) Sym(3);
  1844.     Sym(1) = p;
  1845. }
  1846. ./
  1847.  
  1848. --18.8.5 Productions from 8.6: Constructor Declarations
  1849. --ConstructorModifier ::=
  1850. --      'public'
  1851. --    | 'protected'
  1852. --    | 'private'
  1853. --
  1854. --
  1855. -- The original rule does not contain a "MethodHeaderMarker". See
  1856. -- explanation above.
  1857. --
  1858. -- ConstructorDeclaration ::= Modifiersopt ConstructorDeclarator Throwsopt ConstructorBody
  1859. --
  1860.  
  1861. ConstructorDeclaration ::= Modifiersopt ConstructorDeclarator Throwsopt MethodHeaderMarker ConstructorBody
  1862. \:$action:\
  1863. /.$location
  1864. void Parser::Act$rule_number(void)
  1865. {
  1866.     AstConstructorBlock *block = Sym(5) -> ConstructorBlockCast();
  1867.     if (! block)
  1868.     {
  1869.         block = ast_pool -> NewConstructorBlock();
  1870.         block -> left_brace_token                    = Sym(5) -> LeftToken();
  1871.         block -> explicit_constructor_invocation_opt = NULL;
  1872.         block -> block                               = (AstBlock *) Sym(5);
  1873.         block -> right_brace_token                   = Sym(5) -> RightToken();
  1874.     }
  1875.  
  1876.     AstConstructorDeclaration *p = ast_pool -> NewConstructorDeclaration();
  1877.  
  1878.     if (Sym(1) != NULL)
  1879.     {
  1880.         AstListNode *tail = (AstListNode *) Sym(1);
  1881.         p -> AllocateConstructorModifiers(tail -> index + 1);
  1882.         AstListNode *root = tail;
  1883.         do
  1884.         {
  1885.             root = root -> next;
  1886.             p -> AddConstructorModifier((AstModifier *) root -> element);
  1887.         } while(root != tail);
  1888.         FreeCircularList(tail);
  1889.     }
  1890.     p -> constructor_declarator = (AstMethodDeclarator *) Sym(2);
  1891.     if (Sym(3) != NULL)
  1892.     {
  1893.         AstListNode *tail = (AstListNode *) Sym(3);
  1894.         p -> AllocateThrows(tail -> index + 1);
  1895.         AstListNode *root = tail;
  1896.         do
  1897.         {
  1898.             root = root -> next;
  1899.             p -> AddThrow((AstExpression *) root -> element);
  1900.         } while(root != tail);
  1901.         FreeCircularList(tail);
  1902.     }
  1903.     p -> constructor_body       = block;
  1904.  
  1905.     Sym(1) = p;
  1906. }
  1907. ./
  1908.  
  1909. --
  1910. -- The original rule specifies SimpleName but it appears to be an
  1911. -- error as the rule for a method declarator uses an Identifier.
  1912. --...Until further notice, ...
  1913. --
  1914. -- ConstructorDeclarator ::= SimpleName '(' FormalParameterListopt ')'
  1915. --
  1916.  
  1917. ConstructorDeclarator ::= 'Identifier' '(' FormalParameterListopt ')'
  1918. \:$action:\
  1919. /.$location
  1920. void Parser::Act$rule_number(void)
  1921. {
  1922.     AstMethodDeclarator *p = ast_pool -> NewMethodDeclarator();
  1923.     p -> identifier_token        = Token(1);
  1924.     p -> left_parenthesis_token  = Token(2);
  1925.     if (Sym(3) != NULL)
  1926.     {
  1927.         AstListNode *tail = (AstListNode *) Sym(3);
  1928.         p -> AllocateFormalParameters(tail -> index + 1);
  1929.         AstListNode *root = tail;
  1930.         do
  1931.         {
  1932.             root = root -> next;
  1933.             p -> AddFormalParameter((AstFormalParameter *) root -> element);
  1934.         } while(root != tail);
  1935.         FreeCircularList(tail);
  1936.     }
  1937.     p -> right_parenthesis_token = Token(4);
  1938.     Sym(1) = p;
  1939. }
  1940. ./
  1941.  
  1942. --
  1943. -- NOTE that the rules ExplicitConstructorInvocationopt has been expanded
  1944. -- in the rule below in order to make the grammar lalr(1).
  1945. --
  1946. -- ConstructorBody ::= '{' ExplicitConstructorInvocationopt BlockStatementsopt '}'
  1947. --
  1948. ConstructorBody -> Block
  1949. \:$NoAction:\
  1950. /.$shared_NoAction./
  1951.  
  1952. ConstructorBody ::= '{' ExplicitConstructorInvocation BlockStatementsopt '}'
  1953. \:$action:\
  1954. /.$location
  1955. void Parser::Act$rule_number(void)
  1956. {
  1957.     AstBlock *block = ast_pool -> NewBlock();
  1958.     if (Sym(3) != NULL)
  1959.     {
  1960.         AstListNode *tail = (AstListNode *) Sym(3);
  1961.         block -> AllocateBlockStatements(tail -> index + 1);
  1962.         AstListNode *root = tail;
  1963.         block -> left_brace_token  = root -> element -> LeftToken();
  1964.         block -> right_brace_token = tail -> element -> RightToken();
  1965.         do
  1966.         {
  1967.             root = root -> next;
  1968.             block -> AddStatement((AstStatement *) root -> element);
  1969.         } while(root != tail);
  1970.         FreeCircularList(tail);
  1971.     }
  1972.     else
  1973.     {
  1974.         block -> left_brace_token  = Token(4);
  1975.         block -> right_brace_token = Token(4);
  1976.     }
  1977.  
  1978.     AstConstructorBlock *p = ast_pool -> NewConstructorBlock();
  1979.     p -> left_brace_token                    = Token(1);
  1980.     p -> explicit_constructor_invocation_opt = Sym(2);
  1981.     p -> block                               = block;
  1982.     p -> right_brace_token                   = Token(4);
  1983.     Sym(1) = p;
  1984. }
  1985. ./
  1986.  
  1987. ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
  1988. \:$action:\
  1989. /.$location
  1990. void Parser::Act$rule_number(void)
  1991. {
  1992.     AstThisCall *p = ast_pool -> NewThisCall();
  1993.     p -> base_opt                = NULL;
  1994.     p -> dot_token_opt           = 0;
  1995.     p -> this_token              = Token(1);
  1996.     p -> left_parenthesis_token  = Token(2);
  1997.     if (Sym(3) != NULL)
  1998.     {
  1999.         AstListNode *tail = (AstListNode *) Sym(3);
  2000.         p -> AllocateArguments(tail -> index + 1);
  2001.         AstListNode *root = tail;
  2002.         do
  2003.         {
  2004.             root = root -> next;
  2005.             p -> AddArgument((AstExpression *) root -> element);
  2006.         } while(root != tail);
  2007.         FreeCircularList(tail);
  2008.     }
  2009.     p -> right_parenthesis_token = Token(4);
  2010.     p -> semicolon_token         = Token(5);
  2011.     Sym(1) = p;
  2012. }
  2013. ./
  2014.  
  2015. ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
  2016. \:$action:\
  2017. /.$location
  2018. void Parser::Act$rule_number(void)
  2019. {
  2020.     AstSuperCall *p = ast_pool -> NewSuperCall();
  2021.     p -> base_opt                = NULL;
  2022.     p -> dot_token_opt           = 0;
  2023.     p -> super_token             = Token(1);
  2024.     p -> left_parenthesis_token  = Token(2);
  2025.     if (Sym(3) != NULL)
  2026.     {
  2027.         AstListNode *tail = (AstListNode *) Sym(3);
  2028.         p -> AllocateArguments(tail -> index + 1);
  2029.         AstListNode *root = tail;
  2030.         do
  2031.         {
  2032.             root = root -> next;
  2033.             p -> AddArgument((AstExpression *) root -> element);
  2034.         } while(root != tail);
  2035.         FreeCircularList(tail);
  2036.     }
  2037.     p -> right_parenthesis_token = Token(4);
  2038.     p -> semicolon_token         = Token(5);
  2039.     Sym(1) = p;
  2040. }
  2041. ./
  2042.  
  2043. --1.2 feature
  2044. ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
  2045. \:$action:\
  2046. /.$location
  2047. void Parser::Act$rule_number(void)
  2048. {
  2049.     AstThisCall *p = ast_pool -> NewThisCall();
  2050.     p -> base_opt               = (AstExpression *) Sym(1);
  2051.     p -> dot_token_opt          = Token(2);
  2052.     p -> this_token             = Token(3);
  2053.     p -> left_parenthesis_token = Token(4);
  2054.     if (Sym(5) != NULL)
  2055.     {
  2056.         AstListNode *tail = (AstListNode *) Sym(5);
  2057.         p -> AllocateArguments(tail -> index + 1);
  2058.         AstListNode *root = tail;
  2059.         do
  2060.         {
  2061.             root = root -> next;
  2062.             p -> AddArgument((AstExpression *) root -> element);
  2063.         } while(root != tail);
  2064.         FreeCircularList(tail);
  2065.     }
  2066.     p -> right_parenthesis_token = Token(6);
  2067.     p -> semicolon_token         = Token(7);
  2068.     Sym(1) = p;
  2069. }
  2070. ./
  2071.  
  2072. --1.1 feature
  2073. ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
  2074. \:$MakeQualifiedSuper:\
  2075. /.$location
  2076. void Parser::MakeQualifiedSuper(void)
  2077. {
  2078.     AstSuperCall *p = ast_pool -> NewSuperCall();
  2079.     p -> base_opt                = (AstExpression *) Sym(1);
  2080.     p -> dot_token_opt           = Token(2);
  2081.     p -> super_token             = Token(3);
  2082.     p -> left_parenthesis_token  = Token(4);
  2083.     if (Sym(5) != NULL)
  2084.     {
  2085.         AstListNode *tail = (AstListNode *) Sym(5);
  2086.         p -> AllocateArguments(tail -> index + 1);
  2087.         AstListNode *root = tail;
  2088.         do
  2089.         {
  2090.             root = root -> next;
  2091.             p -> AddArgument((AstExpression *) root -> element);
  2092.         } while(root != tail);
  2093.         FreeCircularList(tail);
  2094.     }
  2095.     p -> right_parenthesis_token = Token(6);
  2096.     p -> semicolon_token         = Token(7);
  2097.     Sym(1) = p;
  2098. }
  2099. ./
  2100.  
  2101. --1.1 feature
  2102. ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
  2103. \:$MakeQualifiedSuper:\
  2104. /.$shared_function
  2105. //
  2106. // void MakeQualifiedSuper(void);
  2107. //./
  2108.  
  2109. --18.9 Productions from 9: Interface Declarations
  2110.  
  2111. --18.9.1 Productions from 9.1: Interface Declarations
  2112. --InterfaceModifier ::=
  2113. --      'public'
  2114. --    | 'abstract'
  2115. --
  2116. InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceBody
  2117. \:$action:\
  2118. /.$location
  2119. void Parser::Act$rule_number(void)
  2120. {
  2121.     AstInterfaceDeclaration *p = (AstInterfaceDeclaration *) Sym(5);
  2122.     if (Sym(1) != NULL)
  2123.     {
  2124.         AstListNode *tail = (AstListNode *) Sym(1);
  2125.         p -> AllocateInterfaceModifiers(tail -> index + 1);
  2126.         AstListNode *root = tail;
  2127.         do
  2128.         {
  2129.             root = root -> next;
  2130.             p -> AddInterfaceModifier((AstModifier *) root -> element);
  2131.         } while(root != tail);
  2132.         FreeCircularList(tail);
  2133.     }
  2134.     p -> interface_token  = Token(2);
  2135.     p -> identifier_token = Token(3);
  2136.     if (Sym(4) != NULL)
  2137.     {
  2138.         AstListNode *tail = (AstListNode *) Sym(4);
  2139.         p -> AllocateExtendsInterfaces(tail -> index + 1);
  2140.         AstListNode *root = tail;
  2141.         do
  2142.         {
  2143.             root = root -> next;
  2144.             p -> AddExtendsInterface((AstExpression *) root -> element);
  2145.         } while(root != tail);
  2146.         FreeCircularList(tail);
  2147.     }
  2148.     Sym(1) = p;
  2149. }
  2150. ./
  2151.  
  2152. ExtendsInterfaces ::= 'extends' InterfaceTypeList
  2153. \:$SetSym1ToSym2:\
  2154. /.$shared_function
  2155. //
  2156. // void SetSym1ToSym2(void);
  2157. //./
  2158.  
  2159. InterfaceBody ::= '{' InterfaceMemberDeclarationsopt '}'
  2160. \:$action:\
  2161. /.$location
  2162. void Parser::Act$rule_number(void)
  2163. {
  2164.     AstInterfaceDeclaration *p = ast_pool -> NewInterfaceDeclaration();
  2165.     if (parse_header_only)
  2166.         p -> mark_unparsed();
  2167.  
  2168.     p -> left_brace_token = Token(1);
  2169.     if (Sym(2) != NULL)
  2170.     {
  2171.         int num_class_variables = 0,
  2172.             num_methods = 0,
  2173.             num_inner_classes = 0,
  2174.             num_inner_interfaces = 0,
  2175.             num_empty_declarations = 0;
  2176.  
  2177.         AstListNode *tail = (AstListNode *) Sym(2);
  2178.         p -> AllocateInterfaceMemberDeclarations(tail -> index + 1);
  2179.         AstListNode *root = tail;
  2180.         do
  2181.         {
  2182.             root = root -> next;
  2183.             p -> AddInterfaceMemberDeclaration(root -> element);
  2184.  
  2185.             AstFieldDeclaration *field_declaration = root -> element -> FieldDeclarationCast();
  2186.             if (field_declaration)
  2187.             {
  2188.                 field_declaration -> MarkStatic();
  2189.                 num_class_variables++;
  2190.             }
  2191.             else if (root -> element -> MethodDeclarationCast())
  2192.             {
  2193.                 num_methods++;
  2194.             }
  2195.             else if (root -> element -> ClassDeclarationCast())
  2196.             {
  2197.                 num_inner_classes++;
  2198.             }
  2199.             else if (root -> element -> InterfaceDeclarationCast())
  2200.             {
  2201.                 num_inner_interfaces++;
  2202.             }
  2203.             else num_empty_declarations++;
  2204.         } while(root != tail);
  2205.  
  2206.         p -> AllocateClassVariables(num_class_variables);
  2207.         p -> AllocateMethods(num_methods);
  2208.         p -> AllocateNestedClasses(num_inner_classes);
  2209.         p -> AllocateNestedInterfaces(num_inner_interfaces);
  2210.         p -> AllocateEmptyDeclarations(num_empty_declarations);
  2211.  
  2212.         root = tail;
  2213.         do
  2214.         {
  2215.             root = root -> next;
  2216.  
  2217.             AstFieldDeclaration *field_declaration;
  2218.             AstMethodDeclaration *method_declaration;
  2219.             AstClassDeclaration *class_declaration;
  2220.             AstInterfaceDeclaration *interface_declaration;
  2221.  
  2222.             if ((field_declaration = root -> element -> FieldDeclarationCast()))
  2223.             {
  2224.                 p -> AddClassVariable(field_declaration);
  2225.             }
  2226.             else if ((method_declaration = root -> element -> MethodDeclarationCast()))
  2227.             {
  2228.                 p -> AddMethod(method_declaration);
  2229.             }
  2230.             else if ((class_declaration = root -> element -> ClassDeclarationCast()))
  2231.             {
  2232.                 p -> AddNestedClass(class_declaration);
  2233.             }
  2234.             else if ((interface_declaration = root -> element -> InterfaceDeclarationCast()))
  2235.             {
  2236.                 p -> AddNestedInterface(interface_declaration);
  2237.             }
  2238.             else // assert(interface_declaration = root -> element -> EmptyDeclarationCast())
  2239.             {
  2240.                 p -> AddEmptyDeclaration((AstEmptyDeclaration *) root -> element);
  2241.             }
  2242.         } while(root != tail);
  2243.         FreeCircularList(tail);
  2244.     }
  2245.     p -> right_brace_token = Token(3);
  2246.     p -> pool = body_pool; // from now on, this is the storage pool to use for this type
  2247.     Sym(1) = p;
  2248. }
  2249. ./
  2250.  
  2251. InterfaceMemberDeclarations ::= InterfaceMemberDeclaration
  2252. \:$action:\
  2253. /.$location
  2254. //
  2255. // Note that the list is circular so as to preserve the order of the elements
  2256. //
  2257. void Parser::Act$rule_number(void)
  2258. {
  2259.     AstListNode *p = AllocateListNode();
  2260.     p -> next = p;
  2261.     p -> element = Sym(1);
  2262.     p -> index = 0;
  2263.  
  2264.     Sym(1) = p;
  2265. }
  2266. ./
  2267.  
  2268. InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
  2269. \:$action:\
  2270. /.$location
  2271. //
  2272. // Note that the list is circular so as to preserve the order of the elements
  2273. //
  2274. void Parser::Act$rule_number(void)
  2275. {
  2276.     AstListNode *tail = (AstListNode *) Sym(1);
  2277.  
  2278.     AstListNode *p = AllocateListNode();
  2279.     p -> element = Sym(2);
  2280.     p -> index = tail -> index + 1;
  2281.  
  2282.     p -> next = tail -> next;
  2283.     tail -> next = p;
  2284.  
  2285.     Sym(1) = p;
  2286. }
  2287. ./
  2288.  
  2289. InterfaceMemberDeclaration -> ConstantDeclaration
  2290. \:$NoAction:\
  2291. /.$shared_NoAction./
  2292.  
  2293. InterfaceMemberDeclaration -> AbstractMethodDeclaration
  2294. \:$NoAction:\
  2295. /.$shared_NoAction./
  2296.  
  2297. --1.1 feature
  2298. InterfaceMemberDeclaration -> ClassDeclaration
  2299. \:$NoAction:\
  2300. /.$shared_NoAction./
  2301.  
  2302. --1.1 feature
  2303. InterfaceMemberDeclaration -> InterfaceDeclaration
  2304. \:$NoAction:\
  2305. /.$shared_NoAction./
  2306.  
  2307. --
  2308. -- Empty declarations are not valid Java InterfaceMemberDeclarations.
  2309. -- However, since the current (2/14/97) Java compiler accepts them
  2310. -- (in fact, some of the official tests contain this erroneous
  2311. -- syntax), we decided to accept them as valid syntax and flag them
  2312. -- as a warning during semantic processing.
  2313. --
  2314. InterfaceMemberDeclaration ::= ';'
  2315. \:$action:\
  2316. /.$location
  2317. void Parser::Act$rule_number(void)
  2318. {
  2319.     Sym(1) = ast_pool -> NewEmptyDeclaration(Token(1));
  2320. }
  2321. ./
  2322.  
  2323. ConstantDeclaration -> FieldDeclaration
  2324. \:$NoAction:\
  2325. /.$shared_NoAction./
  2326.  
  2327. AbstractMethodDeclaration ::= MethodHeader ';'
  2328. \:$action:\
  2329. /.$location
  2330. void Parser::Act$rule_number(void)
  2331. {
  2332.     ((AstMethodDeclaration *) Sym(1)) -> method_body = ast_pool -> NewEmptyStatement(Token(2));
  2333. }
  2334. ./
  2335.  
  2336. --18.10 Productions from 10: Arrays
  2337.  
  2338. --
  2339. -- NOTE that the rules VariableInitializersopt and ,opt have been expanded,
  2340. -- where appropriate, in the rule below in order to make the grammar lalr(1).
  2341. --
  2342. -- ArrayInitializer ::= '{' VariableInitializersopt ,opt '}'
  2343. --
  2344. ArrayInitializer ::= '{' ,opt '}'
  2345. \:$action:\
  2346. /.$location
  2347. void Parser::Act$rule_number(void)
  2348. {
  2349.     AstArrayInitializer *p = ast_pool -> NewArrayInitializer();
  2350.     p -> left_brace_token      = Token(1);
  2351.     p -> right_brace_token     = Token(3);
  2352.     Sym(1) = p;
  2353. }
  2354. ./
  2355.  
  2356. ArrayInitializer ::= '{' VariableInitializers '}'
  2357. \:$action:\
  2358. /.$location
  2359. void Parser::Act$rule_number(void)
  2360. {
  2361.     AstArrayInitializer *p = ast_pool -> NewArrayInitializer();
  2362.     p -> left_brace_token      = Token(1);
  2363.     if (Sym(2) != NULL)
  2364.     {
  2365.         AstListNode *tail = (AstListNode *) Sym(2);
  2366.         p -> AllocateVariableInitializers(tail -> index + 1);
  2367.         AstListNode *root = tail;
  2368.         do
  2369.         {
  2370.             root = root -> next;
  2371.             p -> AddVariableInitializer(root -> element);
  2372.         } while(root != tail);
  2373.         FreeCircularList(tail);
  2374.     }
  2375.     p -> right_brace_token     = Token(3);
  2376.     Sym(1) = p;
  2377. }
  2378. ./
  2379.  
  2380. ArrayInitializer ::= '{' VariableInitializers , '}'
  2381. \:$action:\
  2382. /.$location
  2383. void Parser::Act$rule_number(void)
  2384. {
  2385.     AstArrayInitializer *p = ast_pool -> NewArrayInitializer();
  2386.     p -> left_brace_token      = Token(1);
  2387.     if (Sym(2) != NULL)
  2388.     {
  2389.         AstListNode *tail = (AstListNode *) Sym(2);
  2390.         p -> AllocateVariableInitializers(tail -> index + 1);
  2391.         AstListNode *root = tail;
  2392.         do
  2393.         {
  2394.             root = root -> next;
  2395.             p -> AddVariableInitializer(root -> element);
  2396.         } while(root != tail);
  2397.         FreeCircularList(tail);
  2398.     }
  2399.     p -> right_brace_token     = Token(4);
  2400.     Sym(1) = p;
  2401. }
  2402. ./
  2403.  
  2404. VariableInitializers ::= VariableInitializer
  2405. \:$action:\
  2406. /.$location
  2407. //
  2408. // Note that the list is circular so as to preserve the order of the elements
  2409. //
  2410. void Parser::Act$rule_number(void)
  2411. {
  2412.     AstListNode *p = AllocateListNode();
  2413.     p -> next = p;
  2414.     p -> element = Sym(1);
  2415.     p -> index = 0;
  2416.  
  2417.     Sym(1) = p;
  2418. }
  2419. ./
  2420.  
  2421. VariableInitializers ::= VariableInitializers ',' VariableInitializer
  2422. \:$action:\
  2423. /.$location
  2424. //
  2425. // Note that the list is circular so as to preserve the order of the elements
  2426. //
  2427. void Parser::Act$rule_number(void)
  2428. {
  2429.     AstListNode *tail = (AstListNode *) Sym(1);
  2430.  
  2431.     AstListNode *p = AllocateListNode();
  2432.     p -> element = Sym(3);
  2433.     p -> index = tail -> index + 1;
  2434.  
  2435.     p -> next = tail -> next;
  2436.     tail -> next = p;
  2437.  
  2438.     Sym(1) = p;
  2439. }
  2440. ./
  2441.  
  2442. --18.11 Productions from 13: Blocks and Statements
  2443.  
  2444. Block ::= '{' BlockStatementsopt '}'
  2445. \:$action:\
  2446. /.$location
  2447. void Parser::Act$rule_number(void)
  2448. {
  2449.     AstBlock *p = ast_pool -> NewBlock();
  2450.     p -> left_brace_token  = Token(1);
  2451.     if (Sym(2) != NULL)
  2452.     {
  2453.         AstListNode *tail = (AstListNode *) Sym(2);
  2454.         p -> AllocateBlockStatements(tail -> index + 1);
  2455.         AstListNode *root = tail;
  2456.         do
  2457.         {
  2458.             root = root -> next;
  2459.             p -> AddStatement((AstStatement *) root -> element);
  2460.         } while(root != tail);
  2461.         FreeCircularList(tail);
  2462.     }
  2463.     p -> right_brace_token = Token(3);
  2464.     Sym(1) = p;
  2465. }
  2466. ./
  2467.  
  2468. BlockStatements ::= BlockStatement
  2469. \:$action:\
  2470. /.$location
  2471. //
  2472. // Note that the list is circular so as to preserve the order of the elements
  2473. //
  2474. void Parser::Act$rule_number(void)
  2475. {
  2476.     AstListNode *p = AllocateListNode();
  2477.     p -> next = p;
  2478.     p -> element = Sym(1);
  2479.     p -> index = 0;
  2480.  
  2481.     Sym(1) = p;
  2482. }
  2483. ./
  2484.  
  2485. BlockStatements ::= BlockStatements BlockStatement
  2486. \:$action:\
  2487. /.$location
  2488. //
  2489. // Note that the list is circular so as to preserve the order of the elements
  2490. //
  2491. void Parser::Act$rule_number(void)
  2492. {
  2493.     AstListNode *tail = (AstListNode *) Sym(1);
  2494.  
  2495.     AstListNode *p = AllocateListNode();
  2496.     p -> element = Sym(2);
  2497.     p -> index = tail -> index + 1;
  2498.  
  2499.     p -> next = tail -> next;
  2500.     tail -> next = p;
  2501.  
  2502.     Sym(1) = p;
  2503. }
  2504. ./
  2505.  
  2506. BlockStatement -> LocalVariableDeclarationStatement
  2507. \:$NoAction:\
  2508. /.$shared_NoAction./
  2509.  
  2510. BlockStatement -> Statement
  2511. \:$NoAction:\
  2512. /.$shared_NoAction./
  2513.  
  2514. --1.1 feature
  2515. BlockStatement -> ClassDeclaration
  2516. \:$NoAction:\
  2517. /.$shared_NoAction./
  2518.  
  2519. LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';'
  2520. \:$action:\
  2521. /.$location
  2522. void Parser::Act$rule_number(void)
  2523. {
  2524.     ((AstLocalVariableDeclarationStatement *) Sym(1)) -> semicolon_token_opt = Token(2);
  2525. }
  2526. ./
  2527.  
  2528. LocalVariableDeclaration ::= Type VariableDeclarators
  2529. \:$action:\
  2530. /.$location
  2531. void Parser::Act$rule_number(void)
  2532. {
  2533.     AstLocalVariableDeclarationStatement *p = ast_pool -> NewLocalVariableDeclarationStatement();
  2534.     p -> type                 = Sym(1);
  2535.     //
  2536.     // The list of declarators is guaranteed not empty
  2537.     //
  2538.     {
  2539.         AstListNode *tail = (AstListNode *) Sym(2);
  2540.         p -> AllocateVariableDeclarators(tail -> index + 1);
  2541.         AstListNode *root = tail;
  2542.         do
  2543.         {
  2544.             root = root -> next;
  2545.             p -> AddVariableDeclarator((AstVariableDeclarator *) root -> element);
  2546.         } while(root != tail);
  2547.         FreeCircularList(tail);
  2548.     }
  2549.     p -> semicolon_token_opt  = 0;
  2550.     Sym(1) = p;
  2551. }
  2552. ./
  2553.  
  2554. --1.1 feature
  2555. LocalVariableDeclaration ::= Modifiers Type VariableDeclarators
  2556. \:$action:\
  2557. /.$location
  2558. void Parser::Act$rule_number(void)
  2559. {
  2560.     AstLocalVariableDeclarationStatement *p = ast_pool -> NewLocalVariableDeclarationStatement();
  2561.     //
  2562.     // The list of modifiers is guaranteed not empty
  2563.     //
  2564.     {
  2565.         AstListNode *tail = (AstListNode *) Sym(1);
  2566.         p -> AllocateLocalModifiers(tail -> index + 1);
  2567.         AstListNode *root = tail;
  2568.         do
  2569.         {
  2570.             root = root -> next;
  2571.             p -> AddLocalModifier((AstModifier *) root -> element);
  2572.         } while(root != tail);
  2573.         FreeCircularList(tail);
  2574.     }
  2575.     p -> type = Sym(2);
  2576.     //
  2577.     // The list of declarators is guaranteed not empty
  2578.     //
  2579.     {
  2580.         AstListNode *tail = (AstListNode *) Sym(3);
  2581.         p -> AllocateVariableDeclarators(tail -> index + 1);
  2582.         AstListNode *root = tail;
  2583.         do
  2584.         {
  2585.             root = root -> next;
  2586.             p -> AddVariableDeclarator((AstVariableDeclarator *) root -> element);
  2587.         } while(root != tail);
  2588.         FreeCircularList(tail);
  2589.     }
  2590.     p -> semicolon_token_opt  = 0;
  2591.     Sym(1) = p;
  2592. }
  2593. ./
  2594.  
  2595. Statement -> StatementWithoutTrailingSubstatement
  2596. \:$NoAction:\
  2597. /.$shared_NoAction./
  2598.  
  2599. Statement -> LabeledStatement
  2600. \:$NoAction:\
  2601. /.$shared_NoAction./
  2602.  
  2603. Statement -> IfThenStatement
  2604. \:$NoAction:\
  2605. /.$shared_NoAction./
  2606.  
  2607. Statement -> IfThenElseStatement
  2608. \:$NoAction:\
  2609. /.$shared_NoAction./
  2610.  
  2611. Statement -> WhileStatement
  2612. \:$NoAction:\
  2613. /.$shared_NoAction./
  2614.  
  2615. Statement -> ForStatement
  2616. \:$NoAction:\
  2617. /.$shared_NoAction./
  2618.  
  2619. StatementNoShortIf -> StatementWithoutTrailingSubstatement
  2620. \:$NoAction:\
  2621. /.$shared_NoAction./
  2622.  
  2623. StatementNoShortIf -> LabeledStatementNoShortIf
  2624. \:$NoAction:\
  2625. /.$shared_NoAction./
  2626.  
  2627. StatementNoShortIf -> IfThenElseStatementNoShortIf
  2628. \:$NoAction:\
  2629. /.$shared_NoAction./
  2630.  
  2631. StatementNoShortIf -> WhileStatementNoShortIf
  2632. \:$NoAction:\
  2633. /.$shared_NoAction./
  2634.  
  2635. StatementNoShortIf -> ForStatementNoShortIf
  2636. \:$NoAction:\
  2637. /.$shared_NoAction./
  2638.  
  2639. StatementWithoutTrailingSubstatement -> Block
  2640. \:$NoAction:\
  2641. /.$shared_NoAction./
  2642.  
  2643. StatementWithoutTrailingSubstatement -> EmptyStatement
  2644. \:$NoAction:\
  2645. /.$shared_NoAction./
  2646.  
  2647. StatementWithoutTrailingSubstatement -> ExpressionStatement
  2648. \:$NoAction:\
  2649. /.$shared_NoAction./
  2650.  
  2651. StatementWithoutTrailingSubstatement -> SwitchStatement
  2652. \:$NoAction:\
  2653. /.$shared_NoAction./
  2654.  
  2655. StatementWithoutTrailingSubstatement -> DoStatement
  2656. \:$NoAction:\
  2657. /.$shared_NoAction./
  2658.  
  2659. StatementWithoutTrailingSubstatement -> BreakStatement
  2660. \:$NoAction:\
  2661. /.$shared_NoAction./
  2662.  
  2663. StatementWithoutTrailingSubstatement -> ContinueStatement
  2664. \:$NoAction:\
  2665. /.$shared_NoAction./
  2666.  
  2667. StatementWithoutTrailingSubstatement -> ReturnStatement
  2668. \:$NoAction:\
  2669. /.$shared_NoAction./
  2670.  
  2671. StatementWithoutTrailingSubstatement -> SynchronizedStatement
  2672. \:$NoAction:\
  2673. /.$shared_NoAction./
  2674.  
  2675. StatementWithoutTrailingSubstatement -> ThrowStatement
  2676. \:$NoAction:\
  2677. /.$shared_NoAction./
  2678.  
  2679. StatementWithoutTrailingSubstatement -> TryStatement
  2680. \:$NoAction:\
  2681. /.$shared_NoAction./
  2682.  
  2683. EmptyStatement ::= ';'
  2684. \:$MakeEmptyStatement:\
  2685. /.$shared_function
  2686. //
  2687. // void MakeEmptyStatement(void);
  2688. //./
  2689.  
  2690. LabeledStatement ::= 'Identifier' ':' Statement
  2691. \:$MakeLabeledStatement:\
  2692. /.$location
  2693. void Parser::MakeLabeledStatement(void)
  2694. {
  2695.     AstBlock *p = Sym(3) -> BlockCast();
  2696.  
  2697.     if (! (p && p -> NumStatements() == 1 &&
  2698.            (p -> Statement(0) -> kind == Ast::FOR   ||
  2699.             p -> Statement(0) -> kind == Ast::WHILE ||
  2700.             p -> Statement(0) -> kind == Ast::DO)))
  2701.     {
  2702.         //
  2703.         // When a statement is labeled, it is enclosed in a block.
  2704.         // This is necessary in order to allow the same name to be
  2705.         // reused to label a subsequent statement at the same nesting
  2706.         // level... See ProcessBlock, ProcessStatement,...
  2707.         //
  2708.         p = ast_pool -> NewBlock();
  2709.         p -> AllocateBlockStatements(1); // allocate 1 element
  2710.         p -> left_brace_token  = Token(1);
  2711.         p -> AddStatement((AstStatement *) Sym(3));
  2712.         p -> right_brace_token = Sym(3) -> RightToken();
  2713.     }
  2714.  
  2715.     p -> AddLabel(Token(1)); // add label to statement
  2716.     Sym(1) = p; // The final result is a block containing the labeled-statement
  2717. }
  2718. ./
  2719.  
  2720. LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf
  2721. \:$MakeLabeledStatement:\
  2722. /.$shared_function
  2723. //
  2724. // void MakeLabeledStatement(void);
  2725. //./
  2726.  
  2727. ExpressionStatement ::= StatementExpression ';'
  2728. \:$action:\
  2729. /.$location
  2730. void Parser::Act$rule_number(void)
  2731. {
  2732.     ((AstExpressionStatement *) Sym(1)) -> semicolon_token_opt = Token(2);
  2733. }
  2734. ./
  2735.  
  2736. StatementExpression ::= Assignment
  2737. \:$MakeExpressionStatement:\
  2738. /.$location
  2739. void Parser::MakeExpressionStatement(void)
  2740. {
  2741.     AstExpressionStatement *p = ast_pool -> NewExpressionStatement();
  2742.     p -> expression          = (AstExpression *) Sym(1);
  2743.     p -> semicolon_token_opt = 0;
  2744.     Sym(1) = p;
  2745. }
  2746. ./
  2747.  
  2748. StatementExpression ::= PreIncrementExpression
  2749. \:$MakeExpressionStatement:\
  2750. /.$shared_function
  2751. //
  2752. // void MakeExpressionStatement(void);
  2753. //./
  2754.  
  2755. StatementExpression ::= PreDecrementExpression
  2756. \:$MakeExpressionStatement:\
  2757. /.$shared_function
  2758. //
  2759. // void MakeExpressionStatement(void);
  2760. //./
  2761.  
  2762. StatementExpression ::= PostIncrementExpression
  2763. \:$MakeExpressionStatement:\
  2764. /.$shared_function
  2765. //
  2766. // void MakeExpressionStatement(void);
  2767. //./
  2768.  
  2769. StatementExpression ::= PostDecrementExpression
  2770. \:$MakeExpressionStatement:\
  2771. /.$shared_function
  2772. //
  2773. // void MakeExpressionStatement(void);
  2774. //./
  2775.  
  2776. StatementExpression ::= MethodInvocation
  2777. \:$MakeExpressionStatement:\
  2778. /.$shared_function
  2779. //
  2780. // void MakeExpressionStatement(void);
  2781. //./
  2782.  
  2783. StatementExpression ::= ClassInstanceCreationExpression
  2784. \:$MakeExpressionStatement:\
  2785. /.$shared_function
  2786. //
  2787. // void MakeExpressionStatement(void);
  2788. //./
  2789.  
  2790. IfThenStatement ::=  'if' '(' Expression ')' Statement
  2791. \:$action:\
  2792. /.$location
  2793. void Parser::Act$rule_number(void)
  2794. {
  2795.     AstBlock *block = Sym(5) -> BlockCast();
  2796.     if (! block)
  2797.     {
  2798.         block = ast_pool -> NewBlock();
  2799.         block -> AllocateBlockStatements(1); // allocate 1 element
  2800.         block -> left_brace_token  = Token(5);
  2801.         block -> AddStatement((AstStatement *) Sym(5));
  2802.         block -> right_brace_token = Sym(5) -> RightToken();
  2803.     }
  2804.  
  2805.     AstIfStatement *p = ast_pool -> NewIfStatement();
  2806.     p -> if_token            = Token(1);
  2807.     p -> expression          = (AstExpression *) Sym(3);
  2808.     p -> true_statement      = block;
  2809.     p -> false_statement_opt = NULL;
  2810.     Sym(1) = p;
  2811. }
  2812. ./
  2813.  
  2814. IfThenElseStatement ::=  'if' '(' Expression ')' StatementNoShortIf 'else' Statement
  2815. \:$MakeIfThenElseStatement:\
  2816. /.$location
  2817. void Parser::MakeIfThenElseStatement(void)
  2818. {
  2819.     AstBlock *true_block = Sym(5) -> BlockCast();
  2820.     if (! true_block)
  2821.     {
  2822.         true_block = ast_pool -> NewBlock();
  2823.         true_block -> AllocateBlockStatements(1); // allocate 1 element
  2824.         true_block -> left_brace_token  = Token(5);
  2825.         true_block -> AddStatement((AstStatement *) Sym(5));
  2826.         true_block -> right_brace_token = Sym(5) -> RightToken();
  2827.     }
  2828.  
  2829.     AstBlock *false_block = Sym(7) -> BlockCast();
  2830.     if (! false_block)
  2831.     {
  2832.         false_block = ast_pool -> NewBlock();
  2833.         false_block -> AllocateBlockStatements(1); // allocate 1 element
  2834.         false_block -> left_brace_token  = Token(7);
  2835.         false_block -> AddStatement((AstStatement *) Sym(7));
  2836.         false_block -> right_brace_token = Sym(7) -> RightToken();
  2837.     }
  2838.  
  2839.     AstIfStatement *p = ast_pool -> NewIfStatement();
  2840.     p -> if_token            = Token(1);
  2841.     p -> expression          = (AstExpression *) Sym(3);
  2842.     p -> true_statement      = true_block;
  2843.     p -> false_statement_opt = false_block;
  2844.     Sym(1) = p;
  2845. }
  2846. ./
  2847.  
  2848. IfThenElseStatementNoShortIf ::=  'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf
  2849. \:$MakeIfThenElseStatement:\
  2850. /.$shared_function
  2851. //
  2852. // void MakeIfThenElseStatement(void);
  2853. //./
  2854.  
  2855. SwitchStatement ::= 'switch' '(' Expression ')' SwitchBlock
  2856. \:$action:\
  2857. /.$location
  2858. void Parser::Act$rule_number(void)
  2859. {
  2860.     AstSwitchStatement *p = (AstSwitchStatement *) Sym(5);
  2861.     p -> switch_token = Token(1);
  2862.     p -> expression   = (AstExpression *) Sym(3);
  2863.     Sym(1) = p;
  2864. }
  2865. ./
  2866.  
  2867. SwitchBlock ::= '{' '}'
  2868. \:$action:\
  2869. /.$location
  2870. void Parser::Act$rule_number(void)
  2871. {
  2872.     AstSwitchStatement *p = ast_pool -> NewSwitchStatement();
  2873.  
  2874.     AstBlock *block = ast_pool -> NewBlock();
  2875.     block -> left_brace_token  = Token(1);
  2876.     block -> right_brace_token = Token(2);
  2877.  
  2878.     p -> switch_block = block;
  2879.  
  2880.     Sym(1) = p;
  2881. }
  2882. ./
  2883.  
  2884. SwitchBlock ::= '{' SwitchBlockStatements '}'
  2885. \:$action:\
  2886. /.$location
  2887. void Parser::Act$rule_number(void)
  2888. {
  2889.     AstSwitchStatement *p = ast_pool -> NewSwitchStatement();
  2890.  
  2891.     AstBlock *block = ast_pool -> NewBlock();
  2892.     block -> left_brace_token  = Token(1);
  2893.     if (Sym(2) != NULL)
  2894.     {
  2895.         AstListNode *tail = (AstListNode *) Sym(2);
  2896.         block -> AllocateBlockStatements(tail -> index + 1);
  2897.         AstListNode *root = tail;
  2898.         do
  2899.         {
  2900.             root = root -> next;
  2901.             block -> AddStatement((AstStatement *) root -> element);
  2902.         } while(root != tail);
  2903.         FreeCircularList(tail);
  2904.     }
  2905.     block -> right_brace_token = Token(3);
  2906.  
  2907.     p -> switch_block  = block;
  2908.  
  2909.     Sym(1) = p;
  2910. }
  2911. ./
  2912.  
  2913. SwitchBlock ::= '{' SwitchLabels '}'
  2914. \:$action:\
  2915. /.$location
  2916. void Parser::Act$rule_number(void)
  2917. {
  2918.     AstSwitchStatement *p = ast_pool -> NewSwitchStatement();
  2919.  
  2920.     AstSwitchBlockStatement *q = ast_pool -> NewSwitchBlockStatement();
  2921.     q -> AddStatement(ast_pool -> NewEmptyStatement(Token(Sym(2) -> RightToken())));
  2922.  
  2923.     //
  2924.     // The list of SwitchBlockStatements is never null
  2925.     //
  2926.     {
  2927.         AstListNode *tail = (AstListNode *) Sym(2);
  2928.         q -> AllocateSwitchLabels(tail -> index + 1);
  2929.         AstListNode *root = tail;
  2930.         do
  2931.         {
  2932.             root = root -> next;
  2933.             q -> AddSwitchLabel((AstStatement *) root -> element);
  2934.         } while(root != tail);
  2935.         FreeCircularList(tail);
  2936.     }
  2937.  
  2938.     AstBlock *block = ast_pool -> NewBlock();
  2939.     block -> AllocateBlockStatements(1); // allocate 1 element
  2940.     block -> left_brace_token  = Token(1);
  2941.     block -> AddStatement(q);
  2942.     block -> right_brace_token = Token(3);
  2943.  
  2944.     p -> switch_block  = block;
  2945.  
  2946.     Sym(1) = p;
  2947. }
  2948. ./
  2949.  
  2950. SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
  2951. \:$action:\
  2952. /.$location
  2953. void Parser::Act$rule_number(void)
  2954. {
  2955.     AstSwitchStatement *p = ast_pool -> NewSwitchStatement();
  2956.  
  2957.     AstBlock *block = ast_pool -> NewBlock();
  2958.     block -> left_brace_token  = Token(1);
  2959.     //
  2960.     // The list of SwitchBlockStatements is never null
  2961.     //
  2962.     {
  2963.         AstListNode *tail = (AstListNode *) Sym(2);
  2964.         block -> AllocateBlockStatements(tail -> index + 2); // +1 because of extra statement for additional SwithLabels
  2965.         AstListNode *root = tail;
  2966.         do
  2967.         {
  2968.             root = root -> next;
  2969.             block -> AddStatement((AstStatement *) root -> element);
  2970.         } while(root != tail);
  2971.         FreeCircularList(tail);
  2972.     }
  2973.  
  2974.     AstSwitchBlockStatement *q = ast_pool -> NewSwitchBlockStatement();
  2975.     q -> AddStatement(ast_pool -> NewEmptyStatement(Token(Sym(3) -> RightToken())));
  2976.  
  2977.     //
  2978.     // The list of SwitchLabels is never null
  2979.     //
  2980.     {
  2981.         AstListNode *tail = (AstListNode *) Sym(3);
  2982.         q -> AllocateSwitchLabels(tail -> index + 1);
  2983.         AstListNode *root = tail;
  2984.         do
  2985.         {
  2986.             root = root -> next;
  2987.             q -> AddSwitchLabel(root -> element);
  2988.         } while(root != tail);
  2989.         FreeCircularList(tail);
  2990.     }
  2991.  
  2992.     block -> AddStatement(q);
  2993.     block -> right_brace_token = Token(4);
  2994.  
  2995.     p -> switch_block  = block;
  2996.  
  2997.     Sym(1) = p;
  2998. }
  2999. ./
  3000.  
  3001. SwitchBlockStatements ::= SwitchBlockStatement
  3002. \:$action:\
  3003. /.$location
  3004. //
  3005. // Note that the list is circular so as to preserve the order of the elements
  3006. //
  3007. void Parser::Act$rule_number(void)
  3008. {
  3009.     AstListNode *p = AllocateListNode();
  3010.     p -> next = p;
  3011.     p -> element = Sym(1);
  3012.     p -> index = 0;
  3013.  
  3014.     Sym(1) = p;
  3015. }
  3016. ./
  3017.  
  3018. SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement
  3019. \:$action:\
  3020. /.$location
  3021. //
  3022. // Note that the list is circular so as to preserve the order of the elements
  3023. //
  3024. void Parser::Act$rule_number(void)
  3025. {
  3026.     AstListNode *tail = (AstListNode *) Sym(1);
  3027.  
  3028.     AstListNode *p = AllocateListNode();
  3029.     p -> element = Sym(2);
  3030.     p -> index = tail -> index + 1;
  3031.  
  3032.     p -> next = tail -> next;
  3033.     tail -> next = p;
  3034.  
  3035.     Sym(1) = p;
  3036. }
  3037. ./
  3038.  
  3039. SwitchBlockStatement ::= SwitchLabels BlockStatements
  3040. \:$action:\
  3041. /.$location
  3042. void Parser::Act$rule_number(void)
  3043. {
  3044.     AstSwitchBlockStatement *p = ast_pool -> NewSwitchBlockStatement();
  3045.     //
  3046.     // The list of SwitchLabels is never null
  3047.     //
  3048.     {
  3049.         AstListNode *tail = (AstListNode *) Sym(1);
  3050.         p -> AllocateSwitchLabels(tail -> index + 1);
  3051.         AstListNode *root = tail;
  3052.         do
  3053.         {
  3054.             root = root -> next;
  3055.             p -> AddSwitchLabel(root -> element);
  3056.         } while(root != tail);
  3057.         FreeCircularList(tail);
  3058.     }
  3059.  
  3060.     //
  3061.     // The list of SwitchBlockStatements is never null
  3062.     //
  3063.     {
  3064.         AstListNode *tail = (AstListNode *) Sym(2);
  3065.         p -> AllocateBlockStatements(tail -> index + 1);
  3066.         AstListNode *root = tail;
  3067.         do
  3068.         {
  3069.             root = root -> next;
  3070.             p -> AddStatement((AstStatement *) root -> element);
  3071.         } while(root != tail);
  3072.         FreeCircularList(tail);
  3073.     }
  3074.     Sym(1) = p;
  3075. }
  3076. ./
  3077.  
  3078. SwitchLabels ::= SwitchLabel
  3079. \:$action:\
  3080. /.$location
  3081. //
  3082. // Note that the list is circular so as to preserve the order of the elements
  3083. //
  3084. void Parser::Act$rule_number(void)
  3085. {
  3086.     AstListNode *p = AllocateListNode();
  3087.     p -> next = p;
  3088.     p -> element = Sym(1);
  3089.     p -> index = 0;
  3090.  
  3091.     Sym(1) = p;
  3092. }
  3093. ./
  3094.  
  3095. SwitchLabels ::= SwitchLabels SwitchLabel
  3096. \:$action:\
  3097. /.$location
  3098. //
  3099. // Note that the list is circular so as to preserve the order of the elements
  3100. //
  3101. void Parser::Act$rule_number(void)
  3102. {
  3103.     AstListNode *tail = (AstListNode *) Sym(1);
  3104.  
  3105.     AstListNode *p = AllocateListNode();
  3106.     p -> element = Sym(2);
  3107.     p -> index = tail -> index + 1;
  3108.  
  3109.     p -> next = tail -> next;
  3110.     tail -> next = p;
  3111.  
  3112.     Sym(1) = p;
  3113. }
  3114. ./
  3115.  
  3116. SwitchLabel ::= 'case' ConstantExpression ':'
  3117. \:$action:\
  3118. /.$location
  3119. void Parser::Act$rule_number(void)
  3120. {
  3121.     AstCaseLabel *p = ast_pool -> NewCaseLabel();
  3122.     p -> case_token  = Token(1);
  3123.     p -> expression  = (AstExpression *) Sym(2);
  3124.     p -> colon_token = Token(3);
  3125.     Sym(1) = p;
  3126. }
  3127. ./
  3128.  
  3129. SwitchLabel ::= 'default' ':'
  3130. \:$action:\
  3131. /.$location
  3132. void Parser::Act$rule_number(void)
  3133. {
  3134.     AstDefaultLabel *p = ast_pool -> NewDefaultLabel();
  3135.     p -> default_token = Token(1);
  3136.     p -> colon_token   = Token(2);
  3137.     Sym(1) = p;
  3138. }
  3139. ./
  3140.  
  3141. WhileStatement ::= 'while' '(' Expression ')' Statement
  3142. \:$MakeWhileStatement:\
  3143. /.$location
  3144. void Parser::MakeWhileStatement(void)
  3145. {
  3146.     AstWhileStatement *p = ast_pool -> NewWhileStatement();
  3147.     p -> while_token = Token(1);
  3148.     p -> expression  = (AstExpression *) Sym(3);
  3149.     p -> statement   = (AstStatement *) Sym(5);
  3150.  
  3151.     AstBlock *block = ast_pool -> NewBlock();
  3152.     block -> AllocateBlockStatements(1); // allocate 1 element
  3153.     block -> left_brace_token  = Token(1); // point to 'FOR' keyword
  3154.     block -> AddStatement(p);
  3155.     block -> right_brace_token = Sym(5) -> RightToken(); // point to last token in statement
  3156.  
  3157.     Sym(1) = block;
  3158. }
  3159. ./
  3160.  
  3161. WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf
  3162. \:$MakeWhileStatement:\
  3163. /.$shared_function
  3164. //
  3165. // void MakeWhileStatement(void);
  3166. //./
  3167.  
  3168. DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'
  3169. \:$action:\
  3170. /.$location
  3171. void Parser::Act$rule_number(void)
  3172. {
  3173.     AstDoStatement *p = ast_pool -> NewDoStatement();
  3174.     p -> do_token        = Token(1);
  3175.     p -> statement       = (AstStatement *) Sym(2);
  3176.     p -> while_token     = Token(3);
  3177.     p -> expression      = (AstExpression *) Sym(5);
  3178.     p -> semicolon_token = Token(7);
  3179.  
  3180.     AstBlock *block = ast_pool -> NewBlock();
  3181.     block -> AllocateBlockStatements(1); // allocate 1 element
  3182.     block -> left_brace_token  = Token(1);
  3183.     block -> AddStatement(p);
  3184.     block -> right_brace_token = Token(7);
  3185.  
  3186.     Sym(1) = block;
  3187. }
  3188. ./
  3189.  
  3190. ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement
  3191. \:$MakeForStatement:\
  3192. /.$location
  3193. void Parser::MakeForStatement(void)
  3194. {
  3195.     AstForStatement *p = ast_pool -> NewForStatement();
  3196.     p -> for_token = Token(1);
  3197.     if (Sym(3) != NULL)
  3198.     {
  3199.         AstListNode *tail = (AstListNode *) Sym(3);
  3200.         p -> AllocateForInitStatements(tail -> index + 1);
  3201.         AstListNode *root = tail;
  3202.         do
  3203.         {
  3204.             root = root -> next;
  3205.             p -> AddForInitStatement((AstStatement *) root -> element);
  3206.         } while(root != tail);
  3207.         FreeCircularList(tail);
  3208.     }
  3209.     p -> end_expression_opt = (AstExpression *) Sym(5);
  3210.     if (Sym(7) != NULL)
  3211.     {
  3212.         AstListNode *tail = (AstListNode *) Sym(7);
  3213.         p -> AllocateForUpdateStatements(tail -> index + 1);
  3214.         AstListNode *root = tail;
  3215.         do
  3216.         {
  3217.             root = root -> next;
  3218.             p -> AddForUpdateStatement((AstExpressionStatement *) root -> element);
  3219.         } while(root != tail);
  3220.         FreeCircularList(tail);
  3221.     }
  3222.     p -> statement = (AstStatement *) Sym(9);
  3223.  
  3224.     AstBlock *block = ast_pool -> NewBlock();
  3225.     block -> AllocateBlockStatements(1); // allocate 1 element
  3226.     block -> left_brace_token  = Token(1);
  3227.     block -> AddStatement(p);
  3228.     block -> right_brace_token = Sym(9) -> RightToken();
  3229.  
  3230.     Sym(1) = block;
  3231. }
  3232. ./
  3233.  
  3234. ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
  3235. \:$MakeForStatement:\
  3236. /.$shared_function
  3237. //
  3238. // void MakeForStatement(void);
  3239. //./
  3240.  
  3241. ForInit -> StatementExpressionList
  3242. \:$NoAction:\
  3243. /.$shared_NoAction./
  3244.  
  3245. ForInit ::= LocalVariableDeclaration
  3246. \:$action:\
  3247. /.$location
  3248. //
  3249. // Note that the list is circular so as to preserve the order of the elements
  3250. //
  3251. void Parser::Act$rule_number(void)
  3252. {
  3253.     AstListNode *p = AllocateListNode();
  3254.     p -> next = p;
  3255.     p -> element = Sym(1);
  3256.     p -> index = 0;
  3257.  
  3258.     Sym(1) = p;
  3259. }
  3260. ./
  3261.  
  3262. ForUpdate -> StatementExpressionList
  3263. \:$NoAction:\
  3264. /.$shared_NoAction./
  3265.  
  3266. StatementExpressionList ::= StatementExpression
  3267. \:$action:\
  3268. /.$location
  3269. //
  3270. // Note that the list is circular so as to preserve the order of the elements
  3271. //
  3272. void Parser::Act$rule_number(void)
  3273. {
  3274.     AstListNode *p = AllocateListNode();
  3275.     p -> next = p;
  3276.     p -> element = Sym(1);
  3277.     p -> index = 0;
  3278.  
  3279.     Sym(1) = p;
  3280. }
  3281. ./
  3282.  
  3283. StatementExpressionList ::= StatementExpressionList ',' StatementExpression
  3284. \:$action:\
  3285. /.$location
  3286. //
  3287. // Note that the list is circular so as to preserve the order of the elements
  3288. //
  3289. void Parser::Act$rule_number(void)
  3290. {
  3291.     AstListNode *tail = (AstListNode *) Sym(1);
  3292.  
  3293.     AstListNode *p = AllocateListNode();
  3294.     p -> element = Sym(3);
  3295.     p -> index = tail -> index + 1;
  3296.  
  3297.     p -> next = tail -> next;
  3298.     tail -> next = p;
  3299.  
  3300.     Sym(1) = p;
  3301. }
  3302. ./
  3303.  
  3304. --
  3305. -- NOTE that the rule Identifieropt was expanded in line in the two
  3306. -- contexts where it appeared: Break and Continue statements.
  3307. -- This was done because there is no straightforward way of passing
  3308. -- optional token information in the parse stack.
  3309. --
  3310. BreakStatement ::= 'break' ';'
  3311. \:$action:\
  3312. /.$location
  3313. void Parser::Act$rule_number(void)
  3314. {
  3315.     AstBreakStatement *p = ast_pool -> NewBreakStatement();
  3316.     p -> break_token          = Token(1);
  3317.     p -> identifier_token_opt = 0;
  3318.     p -> semicolon_token      = Token(2);
  3319.     Sym(1) = p;
  3320. }
  3321. ./
  3322.  
  3323. BreakStatement ::= 'break' 'Identifier' ';'
  3324. \:$action:\
  3325. /.$location
  3326. void Parser::Act$rule_number(void)
  3327. {
  3328.     AstBreakStatement *p = ast_pool -> NewBreakStatement();
  3329.     p -> break_token          = Token(1);
  3330.     p -> identifier_token_opt = Token(2);
  3331.     p -> semicolon_token      = Token(3);
  3332.     Sym(1) = p;
  3333. }
  3334. ./
  3335.  
  3336. ContinueStatement ::= 'continue' ';'
  3337. \:$action:\
  3338. /.$location
  3339. void Parser::Act$rule_number(void)
  3340. {
  3341.     AstContinueStatement *p = ast_pool -> NewContinueStatement();
  3342.     p -> continue_token       = Token(1);
  3343.     p -> identifier_token_opt = 0;
  3344.     p -> semicolon_token      = Token(2);
  3345.     Sym(1) = p;
  3346. }
  3347. ./
  3348.  
  3349. ContinueStatement ::= 'continue' 'Identifier' ';'
  3350. \:$action:\
  3351. /.$location
  3352. void Parser::Act$rule_number(void)
  3353. {
  3354.     AstContinueStatement *p = ast_pool -> NewContinueStatement();
  3355.     p -> continue_token       = Token(1);
  3356.     p -> identifier_token_opt = Token(2);
  3357.     p -> semicolon_token      = Token(3);
  3358.     Sym(1) = p;
  3359. }
  3360. ./
  3361.  
  3362. ReturnStatement ::= 'return' Expressionopt ';'
  3363. \:$action:\
  3364. /.$location
  3365. void Parser::Act$rule_number(void)
  3366. {
  3367.     AstReturnStatement *p = ast_pool -> NewReturnStatement();
  3368.     p -> return_token    = Token(1);
  3369.     p -> expression_opt  = (AstExpression *) Sym(2);
  3370.     p -> semicolon_token = Token(3);
  3371.     Sym(1) = p;
  3372. }
  3373. ./
  3374.  
  3375. ThrowStatement ::= 'throw' Expression ';'
  3376. \:$action:\
  3377. /.$location
  3378. void Parser::Act$rule_number(void)
  3379. {
  3380.     AstThrowStatement *p = ast_pool -> NewThrowStatement();
  3381.     p -> throw_token     = Token(1);
  3382.     p -> expression      = (AstExpression *) Sym(2);
  3383.     p -> semicolon_token = Token(3);
  3384.     Sym(1) = p;
  3385. }
  3386. ./
  3387.  
  3388. SynchronizedStatement ::= 'synchronized' '(' Expression ')' Block
  3389. \:$action:\
  3390. /.$location
  3391. void Parser::Act$rule_number(void)
  3392. {
  3393.     AstSynchronizedStatement *p = ast_pool -> NewSynchronizedStatement();
  3394.     p -> synchronized_token = Token(1);
  3395.     p -> expression         = (AstExpression *) Sym(3);
  3396.     p -> block              = (AstBlock *) Sym(5);
  3397.     p -> block -> block_tag = AstBlock::SYNCHRONIZED;
  3398.  
  3399.     Sym(1) = p;
  3400. }
  3401. ./
  3402.  
  3403. TryStatement ::= 'try' Block Catches
  3404. \:$action:\
  3405. /.$location
  3406. void Parser::Act$rule_number(void)
  3407. {
  3408.     AstTryStatement *p = ast_pool -> NewTryStatement();
  3409.     p -> try_token          = Token(1);
  3410.     p -> block              = (AstBlock *) Sym(2);
  3411.  
  3412.     //
  3413.     // The list of modifiers is guaranteed not empty
  3414.     //
  3415.     {
  3416.         AstListNode *tail = (AstListNode *) Sym(3);
  3417.         p -> AllocateCatchClauses(tail -> index + 1);
  3418.         AstListNode *root = tail;
  3419.         do
  3420.         {
  3421.             root = root -> next;
  3422.             p -> AddCatchClause((AstCatchClause *) root -> element);
  3423.         } while(root != tail);
  3424.         FreeCircularList(tail);
  3425.     }
  3426.     p -> finally_clause_opt = NULL;
  3427.     Sym(1) = p;
  3428. }
  3429. ./
  3430.  
  3431. TryStatement ::= 'try' Block Catchesopt Finally
  3432. \:$action:\
  3433. /.$location
  3434. void Parser::Act$rule_number(void)
  3435. {
  3436.     AstTryStatement *p = ast_pool -> NewTryStatement();
  3437.     p -> try_token      = Token(1);
  3438.     p -> block          = (AstBlock *) Sym(2);
  3439.     p -> block -> block_tag = AstBlock::TRY_CLAUSE_WITH_FINALLY;
  3440.  
  3441.     if (Sym(3) != NULL)
  3442.     {
  3443.         AstListNode *tail = (AstListNode *) Sym(3);
  3444.         p -> AllocateCatchClauses(tail -> index + 1);
  3445.         AstListNode *root = tail;
  3446.         do
  3447.         {
  3448.             root = root -> next;
  3449.             p -> AddCatchClause((AstCatchClause *) root -> element);
  3450.         } while(root != tail);
  3451.         FreeCircularList(tail);
  3452.     }
  3453.  
  3454.     for (int i = 0; i < p -> NumCatchClauses(); i++)
  3455.         p -> CatchClause(i) -> block -> block_tag = AstBlock::TRY_CLAUSE_WITH_FINALLY;
  3456.  
  3457.     p -> finally_clause_opt = (AstFinallyClause *) Sym(4);
  3458.  
  3459.     Sym(1) = p;
  3460. }
  3461. ./
  3462.  
  3463. Catches ::= CatchClause
  3464. \:$action:\
  3465. /.$location
  3466. //
  3467. // Note that the list is circular so as to preserve the order of the elements
  3468. //
  3469. void Parser::Act$rule_number(void)
  3470. {
  3471.     AstListNode *p = AllocateListNode();
  3472.     p -> next = p;
  3473.     p -> element = Sym(1);
  3474.     p -> index = 0;
  3475.  
  3476.     Sym(1) = p;
  3477. }
  3478. ./
  3479.  
  3480. Catches ::= Catches CatchClause
  3481. \:$action:\
  3482. /.$location
  3483. //
  3484. // Note that the list is circular so as to preserve the order of the elements
  3485. //
  3486. void Parser::Act$rule_number(void)
  3487. {
  3488.     AstListNode *tail = (AstListNode *) Sym(1);
  3489.  
  3490.     AstListNode *p = AllocateListNode();
  3491.     p -> element = Sym(2);
  3492.     p -> index = tail -> index + 1;
  3493.  
  3494.     p -> next = tail -> next;
  3495.     tail -> next = p;
  3496.  
  3497.     Sym(1) = p;
  3498. }
  3499. ./
  3500.  
  3501. CatchClause ::= 'catch' '(' FormalParameter ')' Block
  3502. \:$action:\
  3503. /.$location
  3504. void Parser::Act$rule_number(void)
  3505. {
  3506.     AstCatchClause *p = ast_pool -> NewCatchClause();
  3507.     p -> catch_token      = Token(1);
  3508.     p -> formal_parameter = (AstFormalParameter *) Sym(3);
  3509.     p -> block            = (AstBlock *) Sym(5);
  3510.  
  3511.     Sym(1) = p;
  3512. }
  3513. ./
  3514.  
  3515. Finally ::= 'finally' Block
  3516. \:$action:\
  3517. /.$location
  3518. void Parser::Act$rule_number(void)
  3519. {
  3520.     AstFinallyClause *p     = ast_pool -> NewFinallyClause();
  3521.     p -> finally_token      = Token(1);
  3522.     p -> block              = (AstBlock *) Sym(2);
  3523.     p -> block -> block_tag = AstBlock::FINALLY;
  3524.  
  3525.     Sym(1) = p;
  3526. }
  3527. ./
  3528.  
  3529. --18.12 Productions from 14: Expressions
  3530.  
  3531. Primary -> PrimaryNoNewArray
  3532. \:$NoAction:\
  3533. /.$shared_NoAction./
  3534.  
  3535. Primary -> ArrayCreationExpression
  3536. \:$NoAction:\
  3537. /.$shared_NoAction./
  3538.  
  3539. PrimaryNoNewArray -> Literal
  3540. \:$NoAction:\
  3541. /.$shared_NoAction./
  3542.  
  3543. PrimaryNoNewArray ::= this
  3544. \:$action:\
  3545. /.$location
  3546. void Parser::Act$rule_number(void)
  3547. {
  3548.     Sym(1) = ast_pool -> NewThisExpression(Token(1));
  3549. }
  3550. ./
  3551.  
  3552. PrimaryNoNewArray ::= '(' Expression ')'
  3553. \:$action:\
  3554. /.$location
  3555. void Parser::Act$rule_number(void)
  3556. {
  3557.     AstParenthesizedExpression *p = ast_pool -> NewParenthesizedExpression();
  3558.     p -> left_parenthesis_token = Token(1);
  3559.     p -> expression = (AstExpression *) Sym(2);
  3560.     p -> right_parenthesis_token = Token(3);
  3561.     Sym(1) = p;
  3562. }
  3563. ./
  3564.  
  3565. PrimaryNoNewArray -> ClassInstanceCreationExpression
  3566. \:$NoAction:\
  3567. /.$shared_NoAction./
  3568.  
  3569. PrimaryNoNewArray -> FieldAccess
  3570. \:$NoAction:\
  3571. /.$shared_NoAction./
  3572.  
  3573. --1.1 feature
  3574. PrimaryNoNewArray ::= Name '.' 'this'
  3575. \:$action:\
  3576. /.$location
  3577. void Parser::Act$rule_number(void)
  3578. {
  3579.     AstFieldAccess *p = ast_pool -> NewFieldAccess(AstFieldAccess::THIS_TAG);
  3580.     p -> base = (AstExpression *) Sym(1);
  3581.     p -> dot_token = Token(2);
  3582.     p -> identifier_token = Token(3);
  3583.     Sym(1) = p;
  3584. }
  3585. ./
  3586.  
  3587. --1.1 feature
  3588. PrimaryNoNewArray ::= Type '.' 'class'
  3589. \:$action:\
  3590. /.$location
  3591. void Parser::Act$rule_number(void)
  3592. {
  3593.     AstFieldAccess *p = ast_pool -> NewFieldAccess(AstFieldAccess::CLASS_TAG);
  3594.     p -> base = ast_pool -> NewTypeExpression(Sym(1));
  3595.     p -> dot_token = Token(2);
  3596.     p -> identifier_token = Token(3);
  3597.     Sym(1) = p;
  3598. }
  3599. ./
  3600.  
  3601. --1.1 feature
  3602. PrimaryNoNewArray ::= 'void' '.' 'class'
  3603. \:$action:\
  3604. /.$location
  3605. void Parser::Act$rule_number(void)
  3606. {
  3607.     AstFieldAccess *p = ast_pool -> NewFieldAccess(AstFieldAccess::CLASS_TAG);
  3608.     p -> base = ast_pool -> NewTypeExpression(ast_pool -> NewPrimitiveType(Ast::VOID_TYPE, Token(1)));
  3609.     p -> dot_token = Token(2);
  3610.     p -> identifier_token = Token(3);
  3611.     Sym(1) = p;
  3612. }
  3613. ./
  3614.  
  3615. PrimaryNoNewArray -> MethodInvocation
  3616. \:$NoAction:\
  3617. /.$shared_NoAction./
  3618.  
  3619. PrimaryNoNewArray -> ArrayAccess
  3620. \:$NoAction:\
  3621. /.$shared_NoAction./
  3622.  
  3623. --1.1 feature
  3624. --
  3625. -- In Java 1.0 a ClassBody could not appear at all in a
  3626. -- ClassInstanceCreationExpression.
  3627. --
  3628. ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
  3629. \:$action:\
  3630. /.$location
  3631. void Parser::Act$rule_number(void)
  3632. {
  3633.     AstClassInstanceCreationExpression *p = ast_pool -> NewClassInstanceCreationExpression();
  3634.     p -> base_opt                = NULL;
  3635.     p -> dot_token_opt           = 0;
  3636.     p -> new_token               = Token(1);
  3637.     p -> class_type              = ast_pool -> NewTypeExpression(Sym(2));
  3638.     p -> left_parenthesis_token  = Token(3);
  3639.     if (Sym(4) != NULL)
  3640.     {
  3641.         AstListNode *tail = (AstListNode *) Sym(4);
  3642.         p -> AllocateArguments(tail -> index + 1);
  3643.         AstListNode *root = tail;
  3644.         do
  3645.         {
  3646.             root = root -> next;
  3647.             p -> AddArgument((AstExpression *) root -> element);
  3648.         } while(root != tail);
  3649.         FreeCircularList(tail);
  3650.     }
  3651.     p -> right_parenthesis_token = Token(5);
  3652.     p -> class_body_opt          = (AstClassBody *) Sym(6);
  3653.     Sym(1) = p;
  3654. }
  3655. ./
  3656.  
  3657. --1.1 feature
  3658. ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
  3659. \:$MakeQualifiedNew:\
  3660. /.$location
  3661. void Parser::MakeQualifiedNew(void)
  3662. {
  3663.     AstClassInstanceCreationExpression *p = ast_pool -> NewClassInstanceCreationExpression();
  3664.     p -> base_opt                = (AstExpression *) Sym(1);
  3665.     p -> dot_token_opt           = Token(2);
  3666.     p -> new_token               = Token(3);
  3667.     p -> class_type              = ast_pool -> NewTypeExpression(Sym(4));
  3668.     p -> left_parenthesis_token  = Token(5);
  3669.     if (Sym(6) != NULL)
  3670.     {
  3671.         AstListNode *tail = (AstListNode *) Sym(6);
  3672.         p -> AllocateArguments(tail -> index + 1);
  3673.         AstListNode *root = tail;
  3674.         do
  3675.         {
  3676.             root = root -> next;
  3677.             p -> AddArgument((AstExpression *) root -> element);
  3678.         } while(root != tail);
  3679.         FreeCircularList(tail);
  3680.     }
  3681.     p -> right_parenthesis_token = Token(7);
  3682.     p -> class_body_opt          = (AstClassBody *) Sym(8);
  3683.     Sym(1) = p;
  3684. }
  3685. ./
  3686.  
  3687. --1.1 feature
  3688. ClassInstanceCreationExpression ::= Name '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
  3689. \:$MakeQualifiedNew:\
  3690. /.$shared_function
  3691. //
  3692. // void MakeQualifiedNew(void);
  3693. //./
  3694.  
  3695. ArgumentList ::= Expression
  3696. \:$action:\
  3697. /.$location
  3698. //
  3699. // Note that the list is circular so as to preserve the order of the elements
  3700. //
  3701. void Parser::Act$rule_number(void)
  3702. {
  3703.     AstListNode *p = AllocateListNode();
  3704.     p -> next = p;
  3705.     p -> element = Sym(1);
  3706.     p -> index = 0;
  3707.  
  3708.     Sym(1) = p;
  3709. }
  3710. ./
  3711.  
  3712. ArgumentList ::= ArgumentList ',' Expression
  3713. \:$action:\
  3714. /.$location
  3715. //
  3716. // Note that the list is circular so as to preserve the order of the elements
  3717. //
  3718. void Parser::Act$rule_number(void)
  3719. {
  3720.     AstListNode *tail = (AstListNode *) Sym(1);
  3721.  
  3722.     AstListNode *p = AllocateListNode();
  3723.     p -> element = Sym(3);
  3724.     p -> index = tail -> index + 1;
  3725.  
  3726.     p -> next = tail -> next;
  3727.     tail -> next = p;
  3728.  
  3729.     Sym(1) = p;
  3730. }
  3731. ./
  3732.  
  3733. ArrayCreationExpression ::= 'new' PrimitiveType DimExprs Dimsopt
  3734. \:$MakeArrayCreationExpression:\
  3735. /.$location
  3736. void Parser::MakeArrayCreationExpression(void)
  3737. {
  3738.     AstArrayCreationExpression *p = ast_pool -> NewArrayCreationExpression();
  3739.     p -> new_token             = Token(1);
  3740.     p -> array_type            = Sym(2);
  3741.     //
  3742.     // The list of DimExprs is never null
  3743.     //
  3744.     {
  3745.         AstListNode *tail = (AstListNode *) Sym(3);
  3746.         p -> AllocateDimExprs(tail -> index + 1);
  3747.         AstListNode *root = tail;
  3748.         do
  3749.         {
  3750.             root = root -> next;
  3751.             p -> AddDimExpr((AstDimExpr *) root -> element);
  3752.         } while(root != tail);
  3753.         FreeCircularList(tail);
  3754.     }
  3755.  
  3756.     if (Sym(4) != NULL)
  3757.     {
  3758.         AstListNode *tail = (AstListNode *) Sym(4);
  3759.         p -> AllocateBrackets(tail -> index + 1);
  3760.         AstListNode *root = tail;
  3761.         do
  3762.         {
  3763.             root = root -> next;
  3764.             p -> AddBrackets((AstBrackets *) root -> element);
  3765.         } while(root != tail);
  3766.         FreeCircularList(tail);
  3767.     }
  3768.     p -> array_initializer_opt = NULL;
  3769.     Sym(1) = p;
  3770. }
  3771. ./
  3772.  
  3773. ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimExprs Dimsopt
  3774. \:$MakeArrayCreationExpression:\
  3775. /.$shared_function
  3776. //
  3777. // void MakeArrayCreationExpression(void);
  3778. //./
  3779.  
  3780. --1.1 feature
  3781. ArrayCreationExpression ::= 'new' ArrayType ArrayInitializer
  3782. \:$action:\
  3783. /.$location
  3784. void Parser::Act$rule_number(void)
  3785. {
  3786.     AstArrayCreationExpression *p = ast_pool -> NewArrayCreationExpression();
  3787.     p -> new_token             = Token(1);
  3788.     p -> array_type            = Sym(2);
  3789.     p -> array_initializer_opt = (AstArrayInitializer *) Sym(3);
  3790.     Sym(1) = p;
  3791. }
  3792. ./
  3793.  
  3794. DimExprs ::= DimExpr
  3795. \:$action:\
  3796. /.$location
  3797. //
  3798. // Note that the list is circular so as to preserve the order of the elements
  3799. //
  3800. void Parser::Act$rule_number(void)
  3801. {
  3802.     AstListNode *p = AllocateListNode();
  3803.     p -> next = p;
  3804.     p -> element = Sym(1);
  3805.     p -> index = 0;
  3806.  
  3807.     Sym(1) = p;
  3808. }
  3809. ./
  3810.  
  3811. DimExprs ::= DimExprs DimExpr
  3812. \:$action:\
  3813. /.$location
  3814. //
  3815. // Note that the list is circular so as to preserve the order of the elements
  3816. //
  3817. void Parser::Act$rule_number(void)
  3818. {
  3819.     AstListNode *tail = (AstListNode *) Sym(1);
  3820.  
  3821.     AstListNode *p = AllocateListNode();
  3822.     p -> element = Sym(2);
  3823.     p -> index = tail -> index + 1;
  3824.  
  3825.     p -> next = tail -> next;
  3826.     tail -> next = p;
  3827.  
  3828.     Sym(1) = p;
  3829. }
  3830. ./
  3831.  
  3832. DimExpr ::= '[' Expression ']'
  3833. \:$action:\
  3834. /.$location
  3835. void Parser::Act$rule_number(void)
  3836. {
  3837.     AstDimExpr *p = ast_pool -> NewDimExpr();
  3838.     p -> left_bracket_token  = Token(1);
  3839.     p -> expression          = (AstExpression *) Sym(2);
  3840.     p -> right_bracket_token = Token(3);
  3841.     Sym(1) = p;
  3842. }
  3843. ./
  3844.  
  3845. Dims ::= '[' ']'
  3846. \:$action:\
  3847. /.$location
  3848. //
  3849. // Note that the list is circular so as to preserve the order of the elements
  3850. //
  3851. void Parser::Act$rule_number(void)
  3852. {
  3853.     AstListNode *p = AllocateListNode();
  3854.     p -> next = p;
  3855.     p -> element = ast_pool -> NewBrackets(Token(1), Token(2));
  3856.     p -> index = 0;
  3857.  
  3858.     Sym(1) = p;
  3859. }
  3860. ./
  3861.  
  3862. Dims ::= Dims '[' ']'
  3863. \:$action:\
  3864. /.$location
  3865. //
  3866. // Note that the list is circular so as to preserve the order of the elements
  3867. //
  3868. void Parser::Act$rule_number(void)
  3869. {
  3870.     AstListNode *tail = (AstListNode *) Sym(1);
  3871.  
  3872.     AstListNode *p = AllocateListNode();
  3873.     p -> element = ast_pool -> NewBrackets(Token(2), Token(3));
  3874.     p -> index = tail -> index + 1;
  3875.  
  3876.     p -> next = tail -> next;
  3877.     tail -> next = p;
  3878.  
  3879.     Sym(1) = p;
  3880. }
  3881. ./
  3882.  
  3883. FieldAccess ::= Primary '.' 'Identifier'
  3884. \:$MakeFieldAccess:\
  3885. /.$shared_function
  3886. //
  3887. // void MakeFieldAccess(void);
  3888. //./
  3889.  
  3890. FieldAccess ::= 'super' '.' 'Identifier'
  3891. \:$MakeSuperFieldAccess:\
  3892. /.$location
  3893. void Parser::MakeSuperFieldAccess(void)
  3894. {
  3895.     Sym(1) = ast_pool -> NewSuperExpression(Token(1));
  3896.  
  3897.     MakeFieldAccess();
  3898. }
  3899. ./
  3900.  
  3901. --1.2 feature
  3902. FieldAccess ::= Name '.' 'super' '.' 'Identifier'
  3903. \:$MakeSuperDoubleFieldAccess:\
  3904. /.$location
  3905. void Parser::MakeSuperDoubleFieldAccess(void)
  3906. {
  3907.     AstFieldAccess *p = ast_pool -> NewFieldAccess();
  3908.  
  3909.          AstFieldAccess *q = ast_pool -> NewFieldAccess(AstFieldAccess::SUPER_TAG);
  3910.          q -> base = (AstExpression *) Sym(1);
  3911.          q -> dot_token = Token(2);
  3912.          q -> identifier_token = Token(3);
  3913.  
  3914.     p -> base = q;
  3915.     p -> dot_token = Token(4);
  3916.     p -> identifier_token = Token(5);
  3917.  
  3918.     Sym(1) = p;
  3919. }
  3920. ./
  3921.  
  3922. MethodInvocation ::= Name '(' ArgumentListopt ')'
  3923. \:$action:\
  3924. /.$location
  3925. void Parser::Act$rule_number(void)
  3926. {
  3927.     AstMethodInvocation *p = ast_pool -> NewMethodInvocation();
  3928.     p -> method                  = (AstExpression *) Sym(1);
  3929.     p -> left_parenthesis_token  = Token(2);
  3930.     if (Sym(3) != NULL)
  3931.     {
  3932.         AstListNode *tail = (AstListNode *) Sym(3);
  3933.         p -> AllocateArguments(tail -> index + 1);
  3934.         AstListNode *root = tail;
  3935.         do
  3936.         {
  3937.             root = root -> next;
  3938.             p -> AddArgument((AstExpression *) root -> element);
  3939.         } while(root != tail);
  3940.         FreeCircularList(tail);
  3941.     }
  3942.     p -> right_parenthesis_token = Token(4);
  3943.     Sym(1) = p;
  3944. }
  3945. ./
  3946.  
  3947. MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')'
  3948. \:$action:\
  3949. /.$location
  3950. void Parser::Act$rule_number(void)
  3951. {
  3952.     MakeFieldAccess();
  3953.  
  3954.     AstMethodInvocation *p = ast_pool -> NewMethodInvocation();
  3955.     p -> method                  = (AstExpression *) Sym(1);
  3956.     p -> left_parenthesis_token  = Token(4);
  3957.     if (Sym(5) != NULL)
  3958.     {
  3959.         AstListNode *tail = (AstListNode *) Sym(5);
  3960.         p -> AllocateArguments(tail -> index + 1);
  3961.         AstListNode *root = tail;
  3962.         do
  3963.         {
  3964.             root = root -> next;
  3965.             p -> AddArgument((AstExpression *) root -> element);
  3966.         } while(root != tail);
  3967.         FreeCircularList(tail);
  3968.     }
  3969.     p -> right_parenthesis_token = Token(6);
  3970.     Sym(1) = p;
  3971. }
  3972. ./
  3973.  
  3974. MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
  3975. \:$action:\
  3976. /.$location
  3977. void Parser::Act$rule_number(void)
  3978. {
  3979.     MakeSuperFieldAccess();
  3980.  
  3981.     AstMethodInvocation *p = ast_pool -> NewMethodInvocation();
  3982.     p -> method                  = (AstExpression *) Sym(1);
  3983.     p -> left_parenthesis_token  = Token(4);
  3984.     if (Sym(5) != NULL)
  3985.     {
  3986.         AstListNode *tail = (AstListNode *) Sym(5);
  3987.         p -> AllocateArguments(tail -> index + 1);
  3988.         AstListNode *root = tail;
  3989.         do
  3990.         {
  3991.             root = root -> next;
  3992.             p -> AddArgument((AstExpression *) root -> element);
  3993.         } while(root != tail);
  3994.         FreeCircularList(tail);
  3995.     }
  3996.     p -> right_parenthesis_token = Token(6);
  3997.     Sym(1) = p;
  3998. }
  3999. ./
  4000.  
  4001. --1.2 feature
  4002. MethodInvocation ::= Name '.' 'super' '.' 'Identifier' '(' ArgumentListopt ')'
  4003. \:$action:\
  4004. /.$location
  4005. void Parser::Act$rule_number(void)
  4006. {
  4007.     MakeSuperDoubleFieldAccess();
  4008.  
  4009.     AstMethodInvocation *p = ast_pool -> NewMethodInvocation();
  4010.     p -> method                  = (AstExpression *) Sym(1);
  4011.     p -> left_parenthesis_token  = Token(6);
  4012.     if (Sym(7) != NULL)
  4013.     {
  4014.         AstListNode *tail = (AstListNode *) Sym(7);
  4015.         p -> AllocateArguments(tail -> index + 1);
  4016.         AstListNode *root = tail;
  4017.         do
  4018.         {
  4019.             root = root -> next;
  4020.             p -> AddArgument((AstExpression *) root -> element);
  4021.         } while(root != tail);
  4022.         FreeCircularList(tail);
  4023.     }
  4024.     p -> right_parenthesis_token = Token(8);
  4025.     Sym(1) = p;
  4026. }
  4027. ./
  4028.  
  4029. ArrayAccess ::= Name '[' Expression ']'
  4030. \:$MakeArrayAccess:\
  4031. /.$location
  4032. void Parser::MakeArrayAccess(void)
  4033. {
  4034.     AstArrayAccess *p = ast_pool -> NewArrayAccess();
  4035.     p -> base                = (AstExpression *) Sym(1);
  4036.     p -> left_bracket_token  = Token(2);
  4037.     p -> expression          = (AstExpression *) Sym(3);
  4038.     p -> right_bracket_token = Token(4);
  4039.     Sym(1) = p;
  4040. }
  4041. ./
  4042.  
  4043. ArrayAccess ::= PrimaryNoNewArray '[' Expression ']'
  4044. \:$MakeArrayAccess:\
  4045. /.$shared_function
  4046. //
  4047. // void MakeArrayAccess(void);
  4048. //./
  4049.  
  4050. PostfixExpression -> Primary
  4051. \:$NoAction:\
  4052. /.$shared_NoAction./
  4053.  
  4054. PostfixExpression -> Name
  4055. \:$NoAction:\
  4056. /.$shared_NoAction./
  4057.  
  4058. PostfixExpression -> PostIncrementExpression
  4059. \:$NoAction:\
  4060. /.$shared_NoAction./
  4061.  
  4062. PostfixExpression -> PostDecrementExpression
  4063. \:$NoAction:\
  4064. /.$shared_NoAction./
  4065.  
  4066. PostIncrementExpression ::= PostfixExpression '++'
  4067. \:$action:\
  4068. /.$location
  4069. void Parser::Act$rule_number(void)
  4070. {
  4071.     AstPostUnaryExpression *p = ast_pool -> NewPostUnaryExpression(AstPostUnaryExpression::PLUSPLUS);
  4072.     p -> expression          = (AstExpression *) Sym(1);
  4073.     p -> post_operator_token = Token(2);
  4074.     Sym(1) = p;
  4075. }
  4076. ./
  4077.  
  4078. PostDecrementExpression ::= PostfixExpression '--'
  4079. \:$action:\
  4080. /.$location
  4081. void Parser::Act$rule_number(void)
  4082. {
  4083.     AstPostUnaryExpression *p = ast_pool -> NewPostUnaryExpression(AstPostUnaryExpression::MINUSMINUS);
  4084.     p -> expression          = (AstExpression *) Sym(1);
  4085.     p -> post_operator_token = Token(2);
  4086.     Sym(1) = p;
  4087. }
  4088. ./
  4089.  
  4090. UnaryExpression -> PreIncrementExpression
  4091. \:$NoAction:\
  4092. /.$shared_NoAction./
  4093.  
  4094. UnaryExpression -> PreDecrementExpression
  4095. \:$NoAction:\
  4096. /.$shared_NoAction./
  4097.  
  4098. UnaryExpression ::= '+' UnaryExpression
  4099. \:$action:\
  4100. /.$location
  4101. void Parser::Act$rule_number(void)
  4102. {
  4103.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::PLUS);
  4104.     p -> pre_operator_token = Token(1);
  4105.     p -> expression         = (AstExpression *) Sym(2);
  4106.     Sym(1) = p;
  4107. }
  4108. ./
  4109.  
  4110. UnaryExpression ::= '-' UnaryExpression
  4111. \:$action:\
  4112. /.$location
  4113. void Parser::Act$rule_number(void)
  4114. {
  4115.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::MINUS);
  4116.     p -> pre_operator_token = Token(1);
  4117.     p -> expression         = (AstExpression *) Sym(2);
  4118.     Sym(1) = p;
  4119. }
  4120. ./
  4121.  
  4122. UnaryExpression -> UnaryExpressionNotPlusMinus
  4123. \:$NoAction:\
  4124. /.$shared_NoAction./
  4125.  
  4126. PreIncrementExpression ::= '++' UnaryExpression
  4127. \:$action:\
  4128. /.$location
  4129. void Parser::Act$rule_number(void)
  4130. {
  4131.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::PLUSPLUS);
  4132.     p -> pre_operator_token = Token(1);
  4133.     p -> expression         = (AstExpression *) Sym(2);
  4134.     Sym(1) = p;
  4135. }
  4136. ./
  4137.  
  4138. PreDecrementExpression ::= '--' UnaryExpression
  4139. \:$action:\
  4140. /.$location
  4141. void Parser::Act$rule_number(void)
  4142. {
  4143.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::MINUSMINUS);
  4144.     p -> pre_operator_token = Token(1);
  4145.     p -> expression         = (AstExpression *) Sym(2);
  4146.     Sym(1) = p;
  4147. }
  4148. ./
  4149.  
  4150. UnaryExpressionNotPlusMinus -> PostfixExpression
  4151. \:$NoAction:\
  4152. /.$shared_NoAction./
  4153.  
  4154. UnaryExpressionNotPlusMinus ::= '~' UnaryExpression
  4155. \:$action:\
  4156. /.$location
  4157. void Parser::Act$rule_number(void)
  4158. {
  4159.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::TWIDDLE);
  4160.     p -> pre_operator_token = Token(1);
  4161.     p -> expression         = (AstExpression *) Sym(2);
  4162.     Sym(1) = p;
  4163. }
  4164. ./
  4165.  
  4166. UnaryExpressionNotPlusMinus ::= '!' UnaryExpression
  4167. \:$action:\
  4168. /.$location
  4169. void Parser::Act$rule_number(void)
  4170. {
  4171.     AstPreUnaryExpression *p = ast_pool -> NewPreUnaryExpression(AstPreUnaryExpression::NOT);
  4172.     p -> pre_operator_token = Token(1);
  4173.     p -> expression         = (AstExpression *) Sym(2);
  4174.     Sym(1) = p;
  4175. }
  4176. ./
  4177.  
  4178. UnaryExpressionNotPlusMinus -> CastExpression
  4179. \:$NoAction:\
  4180. /.$shared_NoAction./
  4181.  
  4182. CastExpression ::= '(' PrimitiveType Dimsopt ')' UnaryExpression
  4183. \:$MakeCastExpression:\
  4184. /.$location
  4185. void Parser::MakeCastExpression(void)
  4186. {
  4187.     AstCastExpression *p = ast_pool -> NewCastExpression();
  4188.     p -> left_parenthesis_token_opt  = Token(1);
  4189.     p -> type_opt                    = Sym(2);
  4190.     if (Sym(3) != NULL)
  4191.     {
  4192.         AstListNode *tail = (AstListNode *) Sym(3);
  4193.         p -> AllocateBrackets(tail -> index + 1);
  4194.         AstListNode *root = tail;
  4195.         do
  4196.         {
  4197.             root = root -> next;
  4198.             p -> AddBrackets((AstBrackets *) root -> element);
  4199.         } while(root != tail);
  4200.         FreeCircularList(tail);
  4201.     }
  4202.     p -> right_parenthesis_token_opt = Token(4);
  4203.     p -> expression                  = (AstExpression *) Sym(5);
  4204.     Sym(1) = p;
  4205. }
  4206. ./
  4207.  
  4208. CastExpression ::= '(' Expression ')' UnaryExpressionNotPlusMinus
  4209. \:$action:\
  4210. /.$location
  4211. void Parser::Act$rule_number(void)
  4212. {
  4213.     //
  4214.     // Note that Expression must be a name - i.e., Sym(2) -> isName() == true
  4215.     // This check is not performed here and should be performed during
  4216.     // semantic processing.
  4217.     //
  4218.     AstCastExpression *p = ast_pool -> NewCastExpression();
  4219.     p -> left_parenthesis_token_opt  = Token(1);
  4220.     p -> type_opt                    = Sym(2);
  4221.     p -> right_parenthesis_token_opt = Token(3);
  4222.     p -> expression                  = (AstExpression *) Sym(4);
  4223.     Sym(1) = p;
  4224. }
  4225. ./
  4226.  
  4227. CastExpression ::= '(' Name Dims ')' UnaryExpressionNotPlusMinus
  4228. \:$MakeCastExpression:\
  4229. /.$shared_function
  4230. //
  4231. // void MakeCastExpression(void);
  4232. //./
  4233.  
  4234. MultiplicativeExpression -> UnaryExpression
  4235. \:$NoAction:\
  4236. /.$shared_NoAction./
  4237.  
  4238. MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
  4239. \:$action:\
  4240. /.$location
  4241. void Parser::Act$rule_number(void)
  4242. {
  4243.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::STAR);
  4244.     p -> left_expression       = (AstExpression *) Sym(1);
  4245.     p -> binary_operator_token = Token(2);
  4246.     p -> right_expression      = (AstExpression *) Sym(3);
  4247.     Sym(1) = p;
  4248. }
  4249. ./
  4250.  
  4251. MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression
  4252. \:$action:\
  4253. /.$location
  4254. void Parser::Act$rule_number(void)
  4255. {
  4256.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::SLASH);
  4257.     p -> left_expression       = (AstExpression *) Sym(1);
  4258.     p -> binary_operator_token = Token(2);
  4259.     p -> right_expression      = (AstExpression *) Sym(3);
  4260.     Sym(1) = p;
  4261. }
  4262. ./
  4263.  
  4264. MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression
  4265. \:$action:\
  4266. /.$location
  4267. void Parser::Act$rule_number(void)
  4268. {
  4269.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::MOD);
  4270.     p -> left_expression       = (AstExpression *) Sym(1);
  4271.     p -> binary_operator_token = Token(2);
  4272.     p -> right_expression      = (AstExpression *) Sym(3);
  4273.     Sym(1) = p;
  4274. }
  4275. ./
  4276.  
  4277. AdditiveExpression -> MultiplicativeExpression
  4278. \:$NoAction:\
  4279. /.$shared_NoAction./
  4280.  
  4281. AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression
  4282. \:$action:\
  4283. /.$location
  4284. void Parser::Act$rule_number(void)
  4285. {
  4286.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::PLUS);
  4287.     p -> left_expression       = (AstExpression *) Sym(1);
  4288.     p -> binary_operator_token = Token(2);
  4289.     p -> right_expression      = (AstExpression *) Sym(3);
  4290.     Sym(1) = p;
  4291. }
  4292. ./
  4293.  
  4294. AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression
  4295. \:$action:\
  4296. /.$location
  4297. void Parser::Act$rule_number(void)
  4298. {
  4299.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::MINUS);
  4300.     p -> left_expression       = (AstExpression *) Sym(1);
  4301.     p -> binary_operator_token = Token(2);
  4302.     p -> right_expression      = (AstExpression *) Sym(3);
  4303.     Sym(1) = p;
  4304. }
  4305. ./
  4306.  
  4307. ShiftExpression -> AdditiveExpression
  4308. \:$NoAction:\
  4309. /.$shared_NoAction./
  4310.  
  4311. ShiftExpression ::= ShiftExpression '<<'  AdditiveExpression
  4312. \:$action:\
  4313. /.$location
  4314. void Parser::Act$rule_number(void)
  4315. {
  4316.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::LEFT_SHIFT);
  4317.     p -> left_expression       = (AstExpression *) Sym(1);
  4318.     p -> binary_operator_token = Token(2);
  4319.     p -> right_expression      = (AstExpression *) Sym(3);
  4320.     Sym(1) = p;
  4321. }
  4322. ./
  4323.  
  4324. ShiftExpression ::= ShiftExpression '>>'  AdditiveExpression
  4325. \:$action:\
  4326. /.$location
  4327. void Parser::Act$rule_number(void)
  4328. {
  4329.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::RIGHT_SHIFT);
  4330.     p -> left_expression       = (AstExpression *) Sym(1);
  4331.     p -> binary_operator_token = Token(2);
  4332.     p -> right_expression      = (AstExpression *) Sym(3);
  4333.     Sym(1) = p;
  4334. }
  4335. ./
  4336.  
  4337. ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression
  4338. \:$action:\
  4339. /.$location
  4340. void Parser::Act$rule_number(void)
  4341. {
  4342.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::UNSIGNED_RIGHT_SHIFT);
  4343.     p -> left_expression       = (AstExpression *) Sym(1);
  4344.     p -> binary_operator_token = Token(2);
  4345.     p -> right_expression      = (AstExpression *) Sym(3);
  4346.     Sym(1) = p;
  4347. }
  4348. ./
  4349.  
  4350. RelationalExpression -> ShiftExpression
  4351. \:$NoAction:\
  4352. /.$shared_NoAction./
  4353.  
  4354. RelationalExpression ::= RelationalExpression '<'  ShiftExpression
  4355. \:$action:\
  4356. /.$location
  4357. void Parser::Act$rule_number(void)
  4358. {
  4359.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::LESS);
  4360.     p -> left_expression       = (AstExpression *) Sym(1);
  4361.     p -> binary_operator_token = Token(2);
  4362.     p -> right_expression      = (AstExpression *) Sym(3);
  4363.     Sym(1) = p;
  4364. }
  4365. ./
  4366.  
  4367. RelationalExpression ::= RelationalExpression '>'  ShiftExpression
  4368. \:$action:\
  4369. /.$location
  4370. void Parser::Act$rule_number(void)
  4371. {
  4372.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::GREATER);
  4373.     p -> left_expression       = (AstExpression *) Sym(1);
  4374.     p -> binary_operator_token = Token(2);
  4375.     p -> right_expression      = (AstExpression *) Sym(3);
  4376.     Sym(1) = p;
  4377. }
  4378. ./
  4379.  
  4380. RelationalExpression ::= RelationalExpression '<=' ShiftExpression
  4381. \:$action:\
  4382. /.$location
  4383. void Parser::Act$rule_number(void)
  4384. {
  4385.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::LESS_EQUAL);
  4386.     p -> left_expression       = (AstExpression *) Sym(1);
  4387.     p -> binary_operator_token = Token(2);
  4388.     p -> right_expression      = (AstExpression *) Sym(3);
  4389.     Sym(1) = p;
  4390. }
  4391. ./
  4392.  
  4393. RelationalExpression ::= RelationalExpression '>=' ShiftExpression
  4394. \:$action:\
  4395. /.$location
  4396. void Parser::Act$rule_number(void)
  4397. {
  4398.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::GREATER_EQUAL);
  4399.     p -> left_expression       = (AstExpression *) Sym(1);
  4400.     p -> binary_operator_token = Token(2);
  4401.     p -> right_expression      = (AstExpression *) Sym(3);
  4402.     Sym(1) = p;
  4403. }
  4404. ./
  4405.  
  4406. RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
  4407. \:$action:\
  4408. /.$location
  4409. void Parser::Act$rule_number(void)
  4410. {
  4411.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::INSTANCEOF);
  4412.     p -> left_expression       = (AstExpression *) Sym(1);
  4413.     p -> binary_operator_token = Token(2);
  4414.     p -> right_expression      = ast_pool -> NewTypeExpression(Sym(3));
  4415.     Sym(1) = p;
  4416. }
  4417. ./
  4418.  
  4419. EqualityExpression -> RelationalExpression
  4420. \:$NoAction:\
  4421. /.$shared_NoAction./
  4422.  
  4423. EqualityExpression ::= EqualityExpression '==' RelationalExpression
  4424. \:$action:\
  4425. /.$location
  4426. void Parser::Act$rule_number(void)
  4427. {
  4428.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::EQUAL_EQUAL);
  4429.     p -> left_expression       = (AstExpression *) Sym(1);
  4430.     p -> binary_operator_token = Token(2);
  4431.     p -> right_expression      = (AstExpression *) Sym(3);
  4432.     Sym(1) = p;
  4433. }
  4434. ./
  4435.  
  4436. EqualityExpression ::= EqualityExpression '!=' RelationalExpression
  4437. \:$action:\
  4438. /.$location
  4439. void Parser::Act$rule_number(void)
  4440. {
  4441.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::NOT_EQUAL);
  4442.     p -> left_expression       = (AstExpression *) Sym(1);
  4443.     p -> binary_operator_token = Token(2);
  4444.     p -> right_expression      = (AstExpression *) Sym(3);
  4445.     Sym(1) = p;
  4446. }
  4447. ./
  4448.  
  4449.  
  4450. AndExpression -> EqualityExpression
  4451. \:$NoAction:\
  4452. /.$shared_NoAction./
  4453.  
  4454. AndExpression ::= AndExpression '&' EqualityExpression
  4455. \:$action:\
  4456. /.$location
  4457. void Parser::Act$rule_number(void)
  4458. {
  4459.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::AND);
  4460.     p -> left_expression       = (AstExpression *) Sym(1);
  4461.     p -> binary_operator_token = Token(2);
  4462.     p -> right_expression      = (AstExpression *) Sym(3);
  4463.     Sym(1) = p;
  4464. }
  4465. ./
  4466.  
  4467. ExclusiveOrExpression -> AndExpression
  4468. \:$NoAction:\
  4469. /.$shared_NoAction./
  4470.  
  4471. ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression
  4472. \:$action:\
  4473. /.$location
  4474. void Parser::Act$rule_number(void)
  4475. {
  4476.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::XOR);
  4477.     p -> left_expression       = (AstExpression *) Sym(1);
  4478.     p -> binary_operator_token = Token(2);
  4479.     p -> right_expression      = (AstExpression *) Sym(3);
  4480.     Sym(1) = p;
  4481. }
  4482. ./
  4483.  
  4484. InclusiveOrExpression -> ExclusiveOrExpression
  4485. \:$NoAction:\
  4486. /.$shared_NoAction./
  4487.  
  4488. InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression
  4489. \:$action:\
  4490. /.$location
  4491. void Parser::Act$rule_number(void)
  4492. {
  4493.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::IOR);
  4494.     p -> left_expression       = (AstExpression *) Sym(1);
  4495.     p -> binary_operator_token = Token(2);
  4496.     p -> right_expression      = (AstExpression *) Sym(3);
  4497.     Sym(1) = p;
  4498. }
  4499. ./
  4500.  
  4501. ConditionalAndExpression -> InclusiveOrExpression
  4502. \:$NoAction:\
  4503. /.$shared_NoAction./
  4504.  
  4505. ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression
  4506. \:$action:\
  4507. /.$location
  4508. void Parser::Act$rule_number(void)
  4509. {
  4510.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::AND_AND);
  4511.     p -> left_expression       = (AstExpression *) Sym(1);
  4512.     p -> binary_operator_token = Token(2);
  4513.     p -> right_expression      = (AstExpression *) Sym(3);
  4514.     Sym(1) = p;
  4515. }
  4516. ./
  4517.  
  4518. ConditionalOrExpression -> ConditionalAndExpression
  4519. \:$NoAction:\
  4520. /.$shared_NoAction./
  4521.  
  4522. ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression
  4523. \:$action:\
  4524. /.$location
  4525. void Parser::Act$rule_number(void)
  4526. {
  4527.     AstBinaryExpression *p = ast_pool -> NewBinaryExpression(AstBinaryExpression::OR_OR);
  4528.     p -> left_expression       = (AstExpression *) Sym(1);
  4529.     p -> binary_operator_token = Token(2);
  4530.     p -> right_expression      = (AstExpression *) Sym(3);
  4531.     Sym(1) = p;
  4532. }
  4533. ./
  4534.  
  4535. ConditionalExpression -> ConditionalOrExpression
  4536. \:$NoAction:\
  4537. /.$shared_NoAction./
  4538.  
  4539. ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
  4540. \:$action:\
  4541. /.$location
  4542. void Parser::Act$rule_number(void)
  4543. {
  4544.     AstConditionalExpression *p = ast_pool -> NewConditionalExpression();
  4545.     p -> test_expression  = (AstExpression *) Sym(1);
  4546.     p -> question_token   = Token(2);
  4547.     p -> true_expression  = (AstExpression *) Sym(3);
  4548.     p -> colon_token      = Token(4);
  4549.     p -> false_expression = (AstExpression *) Sym(5);
  4550.     Sym(1) = p;
  4551. }
  4552. ./
  4553.  
  4554. AssignmentExpression -> ConditionalExpression
  4555. \:$NoAction:\
  4556. /.$shared_NoAction./
  4557.  
  4558. AssignmentExpression -> Assignment
  4559. \:$NoAction:\
  4560. /.$shared_NoAction./
  4561.  
  4562. Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
  4563. \:$action:\
  4564. /.$location
  4565. void Parser::Act$rule_number(void)
  4566. {
  4567.     AstAssignmentExpression *p = (AstAssignmentExpression *) Sym(2);
  4568.     p -> left_hand_side = (AstExpression *) Sym(1);
  4569.     p -> expression     = (AstExpression *) Sym(3);
  4570.     Sym(1) = p;
  4571. }
  4572. ./
  4573.  
  4574. LeftHandSide -> Name
  4575. \:$NoAction:\
  4576. /.$shared_NoAction./
  4577.  
  4578. LeftHandSide -> FieldAccess
  4579. \:$NoAction:\
  4580. /.$shared_NoAction./
  4581.  
  4582. LeftHandSide -> ArrayAccess
  4583. \:$NoAction:\
  4584. /.$shared_NoAction./
  4585.  
  4586. AssignmentOperator ::= '='
  4587. \:$action:\
  4588. /.$location
  4589. void Parser::Act$rule_number(void)
  4590. {
  4591.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::SIMPLE_EQUAL, Token(1));
  4592. }
  4593. ./
  4594.  
  4595. AssignmentOperator ::= '*='
  4596. \:$action:\
  4597. /.$location
  4598. void Parser::Act$rule_number(void)
  4599. {
  4600.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::STAR_EQUAL, Token(1));
  4601. }
  4602. ./
  4603.  
  4604. AssignmentOperator ::= '/='
  4605. \:$action:\
  4606. /.$location
  4607. void Parser::Act$rule_number(void)
  4608. {
  4609.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::SLASH_EQUAL, Token(1));
  4610. }
  4611. ./
  4612.  
  4613. AssignmentOperator ::= '%='
  4614. \:$action:\
  4615. /.$location
  4616. void Parser::Act$rule_number(void)
  4617. {
  4618.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::MOD_EQUAL, Token(1));
  4619. }
  4620. ./
  4621.  
  4622. AssignmentOperator ::= '+='
  4623. \:$action:\
  4624. /.$location
  4625. void Parser::Act$rule_number(void)
  4626. {
  4627.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::PLUS_EQUAL, Token(1));
  4628. }
  4629. ./
  4630.  
  4631. AssignmentOperator ::= '-='
  4632. \:$action:\
  4633. /.$location
  4634. void Parser::Act$rule_number(void)
  4635. {
  4636.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::MINUS_EQUAL, Token(1));
  4637. }
  4638. ./
  4639.  
  4640. AssignmentOperator ::= '<<='
  4641. \:$action:\
  4642. /.$location
  4643. void Parser::Act$rule_number(void)
  4644. {
  4645.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::LEFT_SHIFT_EQUAL, Token(1));
  4646. }
  4647. ./
  4648.  
  4649. AssignmentOperator ::= '>>='
  4650. \:$action:\
  4651. /.$location
  4652. void Parser::Act$rule_number(void)
  4653. {
  4654.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::RIGHT_SHIFT_EQUAL, Token(1));
  4655. }
  4656. ./
  4657.  
  4658. AssignmentOperator ::= '>>>='
  4659. \:$action:\
  4660. /.$location
  4661. void Parser::Act$rule_number(void)
  4662. {
  4663.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::UNSIGNED_RIGHT_SHIFT_EQUAL, Token(1));
  4664. }
  4665. ./
  4666.  
  4667. AssignmentOperator ::= '&='
  4668. \:$action:\
  4669. /.$location
  4670. void Parser::Act$rule_number(void)
  4671. {
  4672.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::AND_EQUAL, Token(1));
  4673. }
  4674. ./
  4675.  
  4676. AssignmentOperator ::= '^='
  4677. \:$action:\
  4678. /.$location
  4679. void Parser::Act$rule_number(void)
  4680. {
  4681.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::XOR_EQUAL, Token(1));
  4682. }
  4683. ./
  4684.  
  4685. AssignmentOperator ::= '|='
  4686. \:$action:\
  4687. /.$location
  4688. void Parser::Act$rule_number(void)
  4689. {
  4690.     Sym(1) = ast_pool -> NewAssignmentExpression(AstAssignmentExpression::IOR_EQUAL, Token(1));
  4691. }
  4692. ./
  4693.  
  4694. Expression -> AssignmentExpression
  4695. \:$NoAction:\
  4696. /.$shared_NoAction./
  4697.  
  4698. ConstantExpression -> Expression
  4699. \:$NoAction:\
  4700. /.$shared_NoAction./
  4701.  
  4702. ---------------------------------------------------------------------------------------
  4703. --
  4704. -- The following rules are for optional nonterminals.
  4705. --
  4706. ---------------------------------------------------------------------------------------
  4707.  
  4708. PackageDeclarationopt ::= $empty
  4709. \:$NullAction:\
  4710. /.$location
  4711. //
  4712. // Given a rule of the form A ::= x1 x2 ... xn
  4713. //
  4714. // Construct a NULL Ast for A.
  4715. //
  4716. void Parser::NullAction(void) { Sym(1) = NULL; }
  4717. ./
  4718.  
  4719. PackageDeclarationopt -> PackageDeclaration
  4720. \:$NoAction:\
  4721. /.$shared_NoAction./
  4722.  
  4723. Superopt ::= $empty
  4724. \:$NullAction:\
  4725. /.$shared_NullAction./
  4726.  
  4727. Superopt -> Super
  4728. \:$NoAction:\
  4729. /.$shared_NoAction./
  4730.  
  4731. Expressionopt ::= $empty
  4732. \:$NullAction:\
  4733. /.$shared_NullAction./
  4734.  
  4735. Expressionopt -> Expression
  4736. \:$NoAction:\
  4737. /.$shared_NoAction./
  4738.  
  4739. --1.1 feature
  4740. ClassBodyopt ::= $empty
  4741. \:$NullAction:\
  4742. /.$shared_NullAction./
  4743.  
  4744. --1.1 feature
  4745. ClassBodyopt -> ClassBody
  4746. \:$NoAction:\
  4747. /.$shared_NoAction./
  4748.  
  4749. ---------------------------------------------------------------------------------------
  4750. --
  4751. -- The rules below are for optional terminal symbols.  An optional comma,
  4752. -- is only used in the context of an array initializer - It is a
  4753. -- "syntactic sugar" that otherwise serves no other purpose. By contrast,
  4754. -- an optional identifier is used in the definition of a break and
  4755. -- continue statement. When the identifier does not appear, a NULL
  4756. -- is produced. When the identifier is present, the user should use the
  4757. -- corresponding Token(i) method. See break statement as an example.
  4758. --
  4759. ---------------------------------------------------------------------------------------
  4760.  
  4761. ,opt ::= $empty
  4762. \:$NullAction:\
  4763. /.$shared_NullAction./
  4764.  
  4765. ,opt -> ,
  4766. \:$NoAction:\
  4767. /.$shared_NoAction./
  4768.  
  4769. ImportDeclarationsopt ::= $empty
  4770. \:$NullAction:\
  4771. /.$shared_NullAction./
  4772.  
  4773. ImportDeclarationsopt -> ImportDeclarations
  4774. \:$NoAction:\
  4775. /.$shared_NoAction./
  4776.  
  4777. TypeDeclarationsopt ::= $empty
  4778. \:$NullAction:\
  4779. /.$shared_NullAction./
  4780.  
  4781. TypeDeclarationsopt -> TypeDeclarations
  4782. \:$NoAction:\
  4783. /.$shared_NoAction./
  4784.  
  4785. ClassBodyDeclarationsopt ::= $empty
  4786. \:$NullAction:\
  4787. /.$shared_NullAction./
  4788.  
  4789. ClassBodyDeclarationsopt -> ClassBodyDeclarations
  4790. \:$NoAction:\
  4791. /.$shared_NoAction./
  4792.  
  4793. Modifiersopt ::= $empty
  4794. \:$NullAction:\
  4795. /.$shared_NullAction./
  4796.  
  4797. Modifiersopt -> Modifiers
  4798. \:$NoAction:\
  4799. /.$shared_NoAction./
  4800.  
  4801. BlockStatementsopt ::= $empty
  4802. \:$NullAction:\
  4803. /.$shared_NullAction./
  4804.  
  4805. BlockStatementsopt -> BlockStatements
  4806. \:$NoAction:\
  4807. /.$shared_NoAction./
  4808.  
  4809. Dimsopt ::= $empty
  4810. \:$NullAction:\
  4811. /.$shared_NullAction./
  4812.  
  4813. Dimsopt -> Dims
  4814. \:$NoAction:\
  4815. /.$shared_NoAction./
  4816.  
  4817. ArgumentListopt ::= $empty
  4818. \:$NullAction:\
  4819. /.$shared_NullAction./
  4820.  
  4821. ArgumentListopt -> ArgumentList
  4822. \:$NoAction:\
  4823. /.$shared_NoAction./
  4824.  
  4825. Throwsopt ::= $empty
  4826. \:$NullAction:\
  4827. /.$shared_NullAction./
  4828.  
  4829. Throwsopt -> Throws
  4830. \:$NoAction:\
  4831. /.$shared_NoAction./
  4832.  
  4833. FormalParameterListopt ::= $empty
  4834. \:$NullAction:\
  4835. /.$shared_NullAction./
  4836.  
  4837. FormalParameterListopt -> FormalParameterList
  4838. \:$NoAction:\
  4839. /.$shared_NoAction./
  4840.  
  4841. Interfacesopt ::= $empty
  4842. \:$NullAction:\
  4843. /.$shared_NullAction./
  4844.  
  4845. Interfacesopt -> Interfaces
  4846. \:$NoAction:\
  4847. /.$shared_NoAction./
  4848.  
  4849. InterfaceMemberDeclarationsopt ::= $empty
  4850. \:$NullAction:\
  4851. /.$shared_NullAction./
  4852.  
  4853. InterfaceMemberDeclarationsopt -> InterfaceMemberDeclarations
  4854. \:$NoAction:\
  4855. /.$shared_NoAction./
  4856.  
  4857. ForInitopt ::= $empty
  4858. \:$NullAction:\
  4859. /.$shared_NullAction./
  4860.  
  4861. ForInitopt -> ForInit
  4862. \:$NoAction:\
  4863. /.$shared_NoAction./
  4864.  
  4865. ForUpdateopt ::= $empty
  4866. \:$NullAction:\
  4867. /.$shared_NullAction./
  4868.  
  4869. ForUpdateopt -> ForUpdate
  4870. \:$NoAction:\
  4871. /.$shared_NoAction./
  4872.  
  4873. ExtendsInterfacesopt ::= $empty
  4874. \:$NullAction:\
  4875. /.$shared_NullAction./
  4876.  
  4877. ExtendsInterfacesopt -> ExtendsInterfaces
  4878. \:$NoAction:\
  4879. /.$shared_NoAction./
  4880.  
  4881. Catchesopt ::= $empty
  4882. \:$NullAction:\
  4883. /.$shared_NullAction./
  4884.  
  4885. Catchesopt -> Catches
  4886. \:$NoAction:\
  4887. /.$shared_NoAction./
  4888.  
  4889. PackageHeaderMarker ::= $empty
  4890. \:$action:\
  4891. /.$location
  4892. //
  4893. // When this function is invoked, if the "parse_package_header_only" flag
  4894. // is turned on, we skip to the end-of-file token.
  4895. //
  4896. void Parser::Act$rule_number(void)
  4897. {
  4898.     if (parse_package_header_only)
  4899.         lex_stream -> Reset(lex_stream -> NumTokens() - 1); // point to the EOF token
  4900.     Sym(1) = NULL;
  4901. }
  4902. ./
  4903.  
  4904. MethodHeaderMarker ::= $empty
  4905. \:$action:\
  4906. /.$location
  4907. //
  4908. // When this function is invoked, if the "parse_header_only" flag
  4909. // is turned on, the body of the method being parsed is skipped.
  4910. //
  4911. void Parser::Act$rule_number(void)
  4912. {
  4913.     if (parse_header_only)
  4914.     {
  4915.         TokenObject token = Token(1);
  4916.  
  4917.         //
  4918.         // If the first token immediately following the method header
  4919.         // is not an open brace, then we have a syntactic error. Do
  4920.         // nothing and let the error recovery take care of it.
  4921.         //
  4922.         if (lex_stream -> Kind(token) == TK_LBRACE)
  4923.             lex_stream -> Reset(lex_stream -> MatchingBrace(token));
  4924.     }
  4925.  
  4926.     Sym(1) = NULL;
  4927. }
  4928. ./
  4929.  
  4930. ---------------------------------------------------------------------------------------
  4931.  
  4932. \:
  4933. #ifndef HEADERS
  4934.     return;
  4935. }
  4936. #endif
  4937. :\
  4938.  
  4939. $names
  4940.  
  4941. BodyMarker ::= '"class Identifier { ... MethodHeader "'
  4942.  
  4943. void ::= ResultType
  4944.  
  4945. PLUS_PLUS ::=    '++'
  4946. MINUS_MINUS ::=    '--'
  4947. EQUAL_EQUAL ::=    '=='
  4948. LESS_EQUAL ::=    '<='
  4949. GREATER_EQUAL ::=    '>='
  4950. NOT_EQUAL ::=    '!='
  4951. LEFT_SHIFT ::=    '<<'
  4952. RIGHT_SHIFT ::=    '>>'
  4953. UNSIGNED_RIGHT_SHIFT ::=    '>>>'
  4954. PLUS_EQUAL ::=    '+='
  4955. MINUS_EQUAL ::=    '-='
  4956. MULTIPLY_EQUAL ::=    '*='
  4957. DIVIDE_EQUAL ::=    '/='
  4958. AND_EQUAL ::=    '&='
  4959. OR_EQUAL ::=    '|='
  4960. XOR_EQUAL ::=    '^='
  4961. REMAINDER_EQUAL ::=    '%='
  4962. LEFT_SHIFT_EQUAL ::=    '<<='
  4963. RIGHT_SHIFT_EQUAL ::=    '>>='
  4964. UNSIGNED_RIGHT_SHIFT_EQUAL ::=    '>>>='
  4965. OR_OR ::=    '||'
  4966. AND_AND ::=    '&&'
  4967.  
  4968. PLUS ::=    '+'
  4969. MINUS ::=    '-'
  4970. NOT ::=    '!'
  4971. REMAINDER ::=    '%'
  4972. XOR ::=    '^'
  4973. AND ::=    '&'
  4974. MULTIPLY ::=    '*'
  4975. OR ::=    '|'
  4976. TWIDDLE ::=    '~'
  4977. DIVIDE ::=    '/'
  4978. GREATER ::=    '>'
  4979. LESS ::=    '<'
  4980. LPAREN ::=    '('
  4981. RPAREN ::=    ')'
  4982. LBRACE ::=    '{'
  4983. RBRACE ::=    '}'
  4984. LBRACKET ::=    '['
  4985. RBRACKET ::=    ']'
  4986. SEMICOLON ::=    ';'
  4987. QUESTION ::=    '?'
  4988. COLON ::=    ':'
  4989. COMMA ::=    ','
  4990. DOT ::=    '.'
  4991. EQUAL ::=    '='
  4992.  
  4993. $end
  4994.